note 100783 deleted from function.array-multisort by danbrown
| From: | danbrown@php.net | Date: | Sat, 06 Nov 2010 15:02:18 +0000 |
| Subject: | note 100783 deleted from function.array-multisort by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-173815@lists.php.net to get a copy of this message | ||
Note Submitter: marcel at nxserver.de
----
there is a bug in your function.
i have marked the line...
it has to be as followed:
<?php
function array_orderby()
{
$args = func_get_args();
$data = array_shift($args);
foreach ($args as $n => $field) {
if (is_string($field)) {
$tmp = array();
foreach ($data as $key => $row)
$tmp[$key] = $row[$field];
-----> $args[$n] = &$tmp;
}
}
$args[] = &$data;
call_user_func_array('array_multisort', $args);
return array_pop($args);
}
?>