php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #15488 Bug in foreach example?
Submitted: 2002-02-10 10:47 UTC Modified: 2002-02-10 10:49 UTC
From: saajan at saajmin dot f9 dot co dot uk Assigned:
Status: Closed Package: Documentation problem
PHP Version: 4.1.1 OS: Windows XP
Private report: No CVE-ID: None
 [2002-02-10 10:47 UTC] saajan at saajmin dot f9 dot co dot uk
I was looking through a php manual that I downloaded yesterday (php_manual_en.pdf.zip) and noticed what looks like an error on page 149 (PDF page 216).  Right at the bottom of the page, there is a foreach() usage example.  Example 2 is as follows:

/* 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) {
print "\$a[$i] => $v.\n";
}

But $i will always be 0, as it is never modified in the loop!  I found the same error in the online manual at http://www.php.net/manual/en/control-structures.foreach.php

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-02-10 10:49 UTC] derick@php.net
This bug has been fixed in CVS.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon May 06 18:01:35 2024 UTC