inspired by Verity , my urge to display my writing talent and random buzz on the internet
This conversation was (allegedly) overheard in a nursery, which won't be disclosed to avoid litigation
Write a standard php loop on the nursery blackboard
Come on, can't be bothered. Are you joking?
foreach( $array as $key => $value ) echo "$key $value";
Wrong! Don't you ever learn proper language usage
What have I done NOW?
Firstly, you should use ArrayObject from SPL and an iterator. That is the right way now. It is more extendable and proper OOP. You'll be able to apply various design patterns then. It gets really neater.
Yeah right. All I want to do is print the bloody thing. It's easier and faster the way I've done it.
Code like yours is not maintainable or enterprise ready. Really - you should plan for the future.
But you asked me to do a loop
What if you want to loop over a different container and not a simple array? Arrays are not even objects
Then I'll write another
And if you want to do the same for ten other things?
If need arises I'll wrap it in a switch or something else. Really, it depends on the case, I think.
You should think in perspective. Design properly.
But why do you have foreach in the language? And while, and the rest of the gang?
They are still there for compatibility reasons.
Really?
It looks like it
I'm really sorry, but don't have the record of the rest of the conversation