note 37186 rejected from language.types.array by didou

From: Date: Thu, 06 Nov 2003 10:15:46 +0000
Subject: note 37186 rejected from language.types.array by didou
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-59976@lists.php.net to get a copy of this message
Note Submitter: pikachurro@hotmail.com ---- 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?

« previous php.notes (#59976) next »