note 18847 added to function.array-unshift

From: Date: Thu, 07 Feb 2002 11:02:55 +0000
Subject: note 18847 added to function.array-unshift
Groups: php.notes 
Request: Send a blank email to php-notes+get-26338@lists.php.net to get a copy of this message
Actually this problem with the keys getting reindexed only happens when the keys are numerical: <?php $a = array("f"=>"five", "s" =>"six", "t" => "twenty"); print_r($a); echo "\n"; foreach($a as $key=>$val) { echo "k: $key v: $val \n"; } array_unshift($a, "zero"); print_r($a); echo "\n"; foreach($a as $key=>$val) { echo "k: $key v: $val \n"; } ?> Array ( [f] => five [s] => six [t] => twenty ) k: f v: five k: s v: six k: t v: twenty Array ( [0] => zero [f] => five [s] => six [t] => twenty ) k: 0 v: zero k: f v: five k: s v: six k: t v: twenty -- http://www.php.net/manual/en/function.array-unshift.php http://master.php.net/manage/user-notes.php?action=edit+18847 http://master.php.net/manage/user-notes.php?action=delete+18847 http://master.php.net/manage/user-notes.php?action=reject+18847

« previous php.notes (#26338) next »