List Info

Thread: note 66887 added to function.array-shift




note 66887 added to function.array-shift
user name
2006-05-31 14:27:33
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.p
hp.net/note/edit/66887
Del: integrated  -- ht
tp://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://m
aster.php.net/note/delete/66887/spam
Del: non-english -- h
ttp://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://ma
ster.php.net/manage/user-notes.php

-- 
PHP Notes Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub
.php

[1]

about | contact  Other archives ( Real Estate discussion Medical topics )