note 54791 added to function.sort
| From: | Carl at osu1 dot php dot net | Date: | Fri, 15 Jul 2005 06:00:04 +0000 |
| Subject: | note 54791 added to function.sort | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-92001@lists.php.net to get a copy of this message | ||
I commonly use "sort" just to recreate the keys in my arrays. I do this because I usually
don't care about the order.
However, I ran into a problem where I did need to keep the order of the array the same. Thus, I
created a small and easy function that does the job for me.
I'd thought I would share it, and I posted it here, because I suspected that many people used
sort similar to myself.
<?php
function array_reindex($array) {
$new = array();
foreach ($array as $value) array_push($new,$value);
return $new;
}
?>
----
Manual Page -- http://www.php.net/manual/en/function.sort.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+54791
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+54791&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+54791&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+54791&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+54791&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+54791&report=yes&reason=non-english
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+54791&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+54791&report=yes
Search -- http://master.php.net/manage/user-notes.php