note 69313 added to ref.array

From: Date: Thu, 31 Aug 2006 10:20:01 +0000
Subject: note 69313 added to ref.array
Groups: php.notes 
Request: Send a blank email to php-notes+get-116535@lists.php.net to get a copy of this message
//using the foreach loop of php instead of a normal //for loop with the sizeof operator after unset is used. $values = array(); array_push($values,"lion"); array_push($values,"elephant"); array_push($values,"cheetah"); array_push($values,"wildebeest"); unset($values[2]); //normal for loop thinks array size is three //when sizoef function is used in conjunction //the for loop. for($i = 0;$i < sizeof($values); $i++) { echo "animals " . $values[$i]. "\n"; } //prints animals lion animals elephant animals echo "\n"; //foreach prints the three values left properly foreach($values as $animals) { echo "animal " . $animals. "\n"; } //prints animal lion animal elephant animal wildebeest //simple but valid ---- Server IP: 66.163.161.117 Probable Submitter: 196.7.18.226 (proxied: 192.168.0.27) ---- 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/ref.array.php Edit -- https://master.php.net/note/edit/69313 Del: integrated -- https://master.php.net/note/delete/69313/integrated Del: useless -- https://master.php.net/note/delete/69313/useless Del: bad code -- https://master.php.net/note/delete/69313/bad+code Del: spam -- https://master.php.net/note/delete/69313/spam Del: non-english -- https://master.php.net/note/delete/69313/non-english Del: in docs -- https://master.php.net/note/delete/69313/in+docs Del: other reasons-- https://master.php.net/note/delete/69313 Reject -- https://master.php.net/note/reject/69313 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#116535) next »