Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $arFirst = array('mama', 'papa', 'horse');
- $arSecond = array('class', 'grandma', 'keyboard');
- $pairArray = array();
- $notPair = array();
- $test = implode(" " , $arFirst);
- $testTwo = implode(" " , $arSecond);
- function count_letter($x) {
- $count = 0;
- for ($i = 0; $i < strlen($x); $i++) {
- if (strpos('euoaiy', $x[$i]) > -1) {
- $count++;
- }
- }
- return $count;
- }
- if(count_letter($test) % 2 ===0) {
- array_unshift($pairArray , $test);
- }else {
- array_unshift($notPair , $test);
- }
- if(count_letter($testTwo) % 2 ===0) {
- array_unshift($pairArray , $testTwo);
- }else {
- array_unshift($notPair , $testTwo);
- }
- $res = array_merge($pairArray,$notPair);
- print_r($res);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement