|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #9441 New feature for foreach control structure
Submitted: 2001-02-25 09:02 UTC Modified: 2009-05-04 15:08 UTC
From: php at leon dot brooks dot fdns dot net Assigned:
Status: Not a bug Package: Feature/Change Request
PHP Version: 4.0.4pl1 OS: (all, using) Linux 2.2.18
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
49 + 22 = ?
Subscribe to this entry?

 [2001-02-25 09:02 UTC] php at leon dot brooks dot fdns dot net
Would find it convenient to do this:

foreach ($filehandle as $line) {
    # process line (line ends stripped off)
fclose ($filehandle);

...and even this...

foreach ($filehandle as $line[]) {
    # $line[0] = whole line sans ends
    # $line[1] = first word (exploded out gawk-like)
    # $line[2] = second word, etc
fclose ($filehandle);

...just a thought.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2002-08-02 09:21 UTC] parham_m_s at hotmail dot com
i recently converted from perl to php and this was the first thing i realized.  The foreach construct should be implemented into files because it's just eyepleasing (and easier) for some people.  The same idea should also be applied to opendir (or even dumping an entire directory tree into an array).
 [2009-05-04 15:08 UTC]
Use file()
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Wed Nov 29 16:01:27 2023 UTC