note 90388 added to control-structures.foreach

From: Date: Sun, 19 Apr 2009 17:03:26 +0000
Subject: note 90388 added to control-structures.foreach
Groups: php.notes 
Request: Send a blank email to php-notes+get-153497@lists.php.net to get a copy of this message
Note that foreach() iterates through an array in the same order that its elements were defined. If you want to iterate through an array in a different order, you will need to sort the array prior to entering the loop. For example: <?php // Iterate through an array in reverse order, // maintaining key association (i.e. for associative arrays) foreach(array_reverse($array, true) as $key=>$value) { . . . } ?> ---- Server IP: 69.147.83.197 Probable Submitter: 76.2.25.104 ---- Manual Page -- http://www.php.net/manual/en/control-structures.foreach.php Edit -- https://master.php.net/note/edit/90388 Del: integrated -- https://master.php.net/note/delete/90388/integrated Del: useless -- https://master.php.net/note/delete/90388/useless Del: bad code -- https://master.php.net/note/delete/90388/bad+code Del: spam -- https://master.php.net/note/delete/90388/spam Del: non-english -- https://master.php.net/note/delete/90388/non-english Del: in docs -- https://master.php.net/note/delete/90388/in+docs Del: other reasons-- https://master.php.net/note/delete/90388 Reject -- https://master.php.net/note/reject/90388 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#153497) next »