note 15249 added to function.array-shift
| From: | RunMaster at gmx dot de | Date: | Mon, 03 Sep 2001 10:32:40 +0000 |
| Subject: | note 15249 added to function.array-shift | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-17559@lists.php.net to get a copy of this message | ||
Note that array_shift() is mixed and returns the REMOVED element, not the shifted array!
A statement like
$array = array_shift( array_flip( $array ) );
returns the first key of $array, not the flipped and shifted $array.
You must use:
$array = array_flip( $array );
array_shift( $array );
to let $array contain the shifted array.
This applies to many functions in the array context so look out for the returned types, before
looking for bugs!
http://php4.globe.de/manual/en/function.array-shift.php