note 119191 added to function.each

From: Date: Mon, 18 Apr 2016 09:21:51 +0000
Subject: note 119191 added to function.each
Groups: php.notes 
Request: Send a blank email to php-notes+get-205256@lists.php.net to get a copy of this message
/* Iterating using objects via each */ class SAI { public function __toString() { return __CLASS__; } } $a = new SAI(); $b = new SAI(); $c = new SAI(); $d = new SAI(); $e = new SAI(); $objarray = array($a,$b,$c,$d,$e); reset($objarray); while (list($key, $val) = each($objarray)) { echo "$key => $val\n"; } //Results 0 => SAI 1 => SAI 2 => SAI 3 => SAI 4 => SAI Warning: each() will also accept objects, but may return unexpected results. It's therefore not recommended to iterate though object properties with each(). ---- Server IP: 72.52.91.14 Probable Submitter: 182.72.236.105 ---- Manual Page -- http://php.net/manual/en/function.each.php Edit -- https://master.php.net/note/edit/119191 Del: integrated -- https://master.php.net/note/delete/119191/integrated Del: useless -- https://master.php.net/note/delete/119191/useless Del: bad code -- https://master.php.net/note/delete/119191/bad+code Del: spam -- https://master.php.net/note/delete/119191/spam Del: non-english -- https://master.php.net/note/delete/119191/non-english Del: in docs -- https://master.php.net/note/delete/119191/in+docs Del: other reasons-- https://master.php.net/note/delete/119191 Reject -- https://master.php.net/note/reject/119191 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#205256) next »