I have been recommended to put a space between foreach and (, among other things. My understanding is that it helps to differentiate between functions and everything else.
I was just working with an array and noticed that you are supposed to unset($value). I looked up unset and it’s a construct. foreach is also a construct. Then I looked and array is also a construct. No one seems to put a space with unset or array, though.
How do you know when to put a space in and not? I use Adobe Dreamweaver, so I just got into a habit of putting a space after every php word that was colored green (like include_once).
JJ
Edit…
It’s possible that it has something to do with keywords http://php.net/manual/en/reserved.keywords.php. I noticed that foreach is a keyword, but array() is also a keyword.
JJ
There’s many different coding conventions for php. The Zend standards seem to be very close to most code I see:
http://framework.zend.com/manual/en/coding-standard.html
Anyway, probably a space after control structure keywords