<?php
$emails = array(
'[email protected]',
'[email protected]',
'[email protected]',
'[email protected]',
'[email protected]',
'[email protected]',
'[email protected]',
'[email protected]',
'[email protected]',
'[email protected]',
'[email protected]',
'[email protected]',
'[email protected]',
'[email protected]',
'[email protected]',
'[email protected]',
'[email protected]',
'[email protected]',
'[email protected]',
'[email protected]',
);
$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>';
申し訳ありませんが、私はちょうど私がPHP Arrays - Sort by Email Address Domain (alternate)
で必要なものを、あなたはこれまでにしようとしているかを示すことができましたか? – mhatch
は、これはあなたが始めるのに役立つかもしれません:http://php.net/manual/en/array.sorting.php – Katie