note 64530 added to control-structures.foreach

From: Date: Tue, 18 Apr 2006 01:52:58 +0000
Subject: note 64530 added to control-structures.foreach
Groups: php.notes 
Request: Send a blank email to php-notes+get-108363@lists.php.net to get a copy of this message
For those of us without PHP5, you can still use references for key and value. I haven't figured out how to get the key by referrence. I tried $key = &key($ary), but that didn't work. I recieved no error message either. <?php reset($ary); while (each($ary)) { $key = key($ary); $val = &$ary[($key ? $key : 0)]; // Seems that key() doesn't return int 0, hence the ternary opp. $val = $val . ' stuff'; // Do stuff to $val } ?> ---- Server IP: 216.194.113.175 Probable Submitter: 65.100.194.45 ---- 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/control-structures.foreach.php Edit -- http://master.php.net/note/edit/64530 Del: integrated -- http://master.php.net/note/delete/64530/integrated Del: useless -- http://master.php.net/note/delete/64530/useless Del: bad code -- http://master.php.net/note/delete/64530/bad+code Del: spam -- http://master.php.net/note/delete/64530/spam Del: non-english -- http://master.php.net/note/delete/64530/non-english Del: in docs -- http://master.php.net/note/delete/64530/in+docs Del: other reasons-- http://master.php.net/note/delete/64530 Reject -- http://master.php.net/note/reject/64530 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#108363) next »