note 15249 deleted from function.array-shift by nlopess
| From: | nlopess@php.net | Date: | Mon, 24 May 2004 13:20:04 +0000 |
| Subject: | note 15249 deleted from function.array-shift by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-70019@lists.php.net to get a copy of this message | ||
Note Submitter: RunMaster@gmx.de
----
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!