I was wondering how PHP handles an anonymous array, if I make use of it like this:
foreach(array('a', 'b') as $foo) {
// ...
}
This wouldn’t work if the array gets recreated on every step – but it works, so it looks like PHP creates a variable for that array (or something similar, doesn’t really matter) – meaning this wouldn’t actually have a bad perfomance. But is there any point why not to use anonymous arrays with foreach loops? (it kinda “looks wrong/bad” to me)
That’s a perfectly normal array, and such, should work.
Your terminology is quite weird, the term anonymous makes sense for functions, because normally the have names, but for arrays? Is an integer anonymous if you don’t directly assign it to a variable? 🙂 Nah..