php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #63317 Add alternate, more logical foreach syntax
Submitted: 2012-10-20 11:19 UTC Modified: 2013-03-15 14:24 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: evertvandansen at ymail dot com Assigned:
Status: Wont fix Package: Unknown/Other Function
PHP Version: 5.4.8 OS: Any
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: evertvandansen at ymail dot com
New email:
PHP Version: OS:

 

 [2012-10-20 11:19 UTC] evertvandansen at ymail dot com
Description:
------------
This is a very low priority request for adding an alternate foreach syntax. Right 
now we write something like:
foreach ($cats as $cat)
Which is fine, but neither semantically nor grammatically correct. I would propose 
that 
foreach ($cat in $cats) or foreach ($cat from $cats)
makes much more sense and is more readable. Not just from a grammatical point of 
view, but also because that way the actual identifier you use in the iteration is 
placed first.
The existing syntax should obviously remain, it is simply an alternate syntax, not 
meant to substitute.
Again, it is not a very important request as it does not improve PHP technically, 
only in regards to readability and (for some) usability.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-03-15 14:24 UTC] nikic@php.net
-Status: Open +Status: Wont fix
 [2013-03-15 14:24 UTC] nikic@php.net
Don't think this will happen as it doesn't have any (quantifiable) advantages over the current syntax but would a) introduce two ways to do the same thing and b) add a new keyword that is very likely be currently in use. Marking Won't Fix.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 05 07:01:32 2024 UTC