PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
That got it. I am not sure why, but the foreach loop has always been confusing to me. I do like using them better than for loops for messing with arrays.
Mordred wrote:Learn to use single quotes whenever possible btw
what does that mean?
If you won't use variable substitution ("This $var will be substituted"), it is good to 'train' yourself to use single quotes: 'Single quotes for static strings'. It is by no means fatal to use double quotes, but there is significant performance gain in single quotes, if such things matter to you.
Mordred wrote:It is by no means fatal to use double quotes, but there is significant performance gain in single quotes, if such things matter to you.
This was correct years ago (although the "performance gain" never was "significant"), modern versions of php generate exactly the same opcode for echo 'XYZ' and echo "XYZ".
I was left with the (wrong) impression that the php parser is used for double-quoted strings, while apparently this is done only if the string contains unescaped $-s.