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

From: Date: Mon, 14 Jan 2008 12:01:20 +0000
Subject: #43837 [Opn->Bgs]: Unclear Example in Control Structures foreach
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-443@lists.php.net to get a copy of this message
ID: 43837 Updated by: rquadling@php.net Reported By: php at wallbash dot com -Status: Open +Status: Bogus Bug Type: Documentation problem PHP Version: Irrelevant New Comment: 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(). Previous Comments: ------------------------------------------------------------------------ [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 (#443) next »