Syntactic Sugar no PHP


Is foreach an implementation of Syntactic Sugar in PHP?

foreach($array as $key=>$values) {
    //Faz algo com as chaves e valores.


Yes, if once you wouldn't need it to get such a result, as well as many other functions: while and do while .

But, languages ​​must evolve and this ends up being considered natural over time (after all, nobody wants to be writing for repetitions with if and GOTO ).

Scroll to Top