php foreach syntax without {}
foreach, php
Solution
Treat `foreach` and `{ ... }` as 2 different and independent language constructs.
The original `foreach` syntax is
foreach (...)
statement
`echo $item;` is a valid statement.
`{ // any code here }` is a single valid statement as well.
Problem
I was reading through a php to python article which was talking about pythons equivalent of `foreach()` they gave the php code example as ``` foreach ( $items as $item ) echo $item; ``` Is this a valid syntax without the `{}` ive always seen it written as ``` foreach ( $items as $item ){ echo $item; } ``` I ran the first example through coderunner locally to see if it would through an error and it didnt, is this a valid syntax to use or will i run into problems using it ?