note 66887 added to function.array-shift

From: Date: Wed, 31 May 2006 14:27:33 +0000
Subject: note 66887 added to function.array-shift
Groups: php.notes 
Request: Send a blank email to php-notes+get-112645@lists.php.net to get a copy of this message
If the array has non-numerical keys, array_shift extracts the first element, whichever is the key, and recompute the numerical keys, if there are any. Ie : $array = array("c" => "ccc", 0 => "aaa", "d" => "ddd", 5 => "bbb"); $first = array_shift($array); echo '$first = ' . $first . ', $array = ' . var_export($array, true); will display : $first = ccc, $array = array ( 0 => 'aaa', 'd' => 'ddd', 1 => 'bbb', ) It means that array_shift works with associative arrays too, and leaves the keys unchanged if they are non-numerical. ---- Server IP: 66.163.161.117 Probable Submitter: 82.225.190.16 ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/function.array-shift.php Edit -- http://master.php.net/note/edit/66887 Del: integrated -- http://master.php.net/note/delete/66887/integrated Del: useless -- http://master.php.net/note/delete/66887/useless Del: bad code -- http://master.php.net/note/delete/66887/bad+code Del: spam -- http://master.php.net/note/delete/66887/spam Del: non-english -- http://master.php.net/note/delete/66887/non-english Del: in docs -- http://master.php.net/note/delete/66887/in+docs Del: other reasons-- http://master.php.net/note/delete/66887 Reject -- http://master.php.net/note/reject/66887 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#112645) next »