#43837 [Bgs->Csd]: Unclear Example in Control Structures foreach

From: Date: Fri, 18 Jan 2008 11:13:34 +0000
Subject: #43837 [Bgs->Csd]: Unclear Example in Control Structures foreach
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-452@lists.php.net to get a copy of this message
ID: 43837 Updated by: sammywg@php.net Reported By: php at wallbash dot com -Status: Bogus +Status: Closed Bug Type: Documentation problem PHP Version: Irrelevant -Assigned To: +Assigned To: sammywg New Comment: This bug has been fixed in the documentation's XML sources. Since the online and downloadable versions of the documentation need some time to get updated, we would like to ask you to be a bit patient. Thank you for the report, and for helping us make our documentation better. Previous Comments: ------------------------------------------------------------------------ [2008-01-14 12:01:19] rquadling@php.net Example 2 is only showing the value. The "key" here is manually controlled and only shown to make some sense in the output. Example 3 is the example you would be looking at to see the key and value from the foreach(). ------------------------------------------------------------------------ [2008-01-14 10:52:13] php at wallbash dot com Description: ------------ I think this was introduced with #15488. It states "/* foreach example 2: value (with key printed for illustration) */" but the example doesn't really print that key. Thanks Reproduce code: --------------- http://www.php.net/manual/en/control-structures.foreach.php Expected result: ---------------- /* foreach example 2: value (with key printed for illustration) */ $a = array(1, 2, 3, 17); foreach ($a as $i => $v) { echo "\$a[$i] => $v.\n"; } Actual result: -------------- /* foreach example 2: value (with key printed for illustration) */ $a = array(1, 2, 3, 17); $i = 0; /* for illustrative purposes only */ foreach ($a as $v) { echo "\$a[$i] => $v.\n"; $i++; } ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=43837&edit=1

« previous php.doc.bugs (#452) next »