<?php
$emails = array(
'mail1@gmail.com',
'mail2@gmail.com',
'mail3@gmail.com',
'mail4@gmail.com',
'mail5@gmail.com',
'mail1@yahoo.com',
'mail2@yahoo.com',
'mail3@yahoo.com',
'mail4@yahoo.com',
'mail5@yahoo.com',
'mail1@aol.com',
'mail2@aol.com',
'mail3@aol.com',
'mail4@aol.com',
'mail5@aol.com',
'mail1@e.com',
'mail2@others.com',
'mail3@d.com',
'mail4@others.com',
'mail5@z.com',
);
$organized_emails = array();
$needle_key = 0;
$needle_search = array('gmail', 'yahoo', 'aol', 'others');
while(true) {
$current_value = array_shift($emails);
if(strpos($current_value, $needle_search[$needle_key]) !== false) {
$organized_emails[] = $current_value;
$needle_key++;
if($needle_key > 3) {
$needle_key = 0;
}
} else {
array_push($emails, $current_value);
}
if(empty($emails)) {
break;
}
}
echo '<pre>';
print_r($organized_emails);
echo '</pre>';
- Output for 4.3.0 - 4.3.11, 4.4.0 - 4.4.9, 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.24 - 5.5.35, 5.6.8 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.10, 7.2.0 - 7.2.33, 7.3.12 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Process exited with code 137.
preferences:
215.58 ms | 406 KiB | 312 Q