Mike Willbanks wrote on 20/01/2015 03:30:
I am very familiar with the in operator.  However,  the implementation
would be incomplete without handling loops via the in operator.  Many
people when seeing an in operator also think of JavaScript.  In that case
the in operator iterates over properties.  As such in PHP we should be able
to iterate over associative arrays should the syntax be added.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...in

I don't really see how this is related to the in operator, other than that some languages reuse the same keyword for both purposes.

My immediate association when I saw this proposal was not "ah, like the loop syntax in JavaScript", but "ah, like the IN() operator in SQL".

Given the ability to write foreach ( $foo as $key => $value ), I'm not sure adding a variant syntax of for ( $key in $foo ) has that much value for PHP.

Regards,
--
Rowan Collins
[IMSoP]

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to