note 75957 added to function.sort
| From: | sinan at sinaneldem dot com | Date: | Sun, 24 Jun 2007 03:29:01 +0000 |
| Subject: | note 75957 added to function.sort | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-127910@lists.php.net to get a copy of this message | ||
here is little script which will merge arrays, remove duplicates and sort it by alphabetical order:
<?php
$array1 = array('apple', 'banana','pear');
$array2 = array('grape', 'pear','orange');
function array_unique_merge_sort($array1, $array2){
$array = array_unique(array_merge($array1, $array2));
sort($array);
foreach ($array as $key => $value) {
$new[$key] = $value;
}
return $new;
}
print_r (array_unique_merge_sort($array1, $array2));
?>
this will print out:
Array ( [0] => apple [1] => banana [2] => grape [3] => orange [4] => pear )
----
Server IP: 85.111.6.23
Probable Submitter: 85.111.6.6 (proxied: 85.103.251.199)
----
Manual Page -- http://www.php.net/manual/en/function.sort.php
Edit -- https://master.php.net/note/edit/75957
Del: integrated -- https://master.php.net/note/delete/75957/integrated
Del: useless -- https://master.php.net/note/delete/75957/useless
Del: bad code -- https://master.php.net/note/delete/75957/bad+code
Del: spam -- https://master.php.net/note/delete/75957/spam
Del: non-english -- https://master.php.net/note/delete/75957/non-english
Del: in docs -- https://master.php.net/note/delete/75957/in+docs
Del: other reasons-- https://master.php.net/note/delete/75957
Reject -- https://master.php.net/note/reject/75957
Search -- https://master.php.net/manage/user-notes.php