note 37186 added to language.types.array

From: Date: Thu, 06 Nov 2003 09:56:57 +0000
Subject: note 37186 added to language.types.array
Groups: php.notes 
Request: Send a blank email to php-notes+get-59975@lists.php.net to get a copy of this message
When i followed the array tutorial i cut and pasted following code: <?php echo "<hr>\n"; $a = array(1 => 'one', 2 => 'two', 3 => 'three'); echo "\$a: "; print_r($a); echo "<br>\n"; unset($a[2]); /* will produce an array that would have been defined as $a = array(1 => 'one', 3 => 'three'); and NOT $a = array(1 => 'one', 2 =>'three'); */ echo "\$a: "; print_r($a); echo "<br>\n"; $b = array_values($a); // Now b is array(1 => 'one', 2 =>'three') echo "\$b: "; print_r($b); ?> Here you claim when the array is reindexed the array would be: // Now b is array(1 => 'one', 2 =>'three') Infact when i use print_r($b); the result is following: Array ( [0] => one [1] => three ) Is it something wrong here or did i misunderstood the point? ---- Manual Page -- http://www.php.net/manual/en/language.types.array.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+37186 Delete -- http://master.php.net/manage/user-notes.php?action=delete+37186&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+37186&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#59975) next »