Here’s a fun little trick. When looping over an array, you can access the values by reference. Instead of:
foreach ($things as $i => $thing) { $things[$i] = strtolower($thing); }
You can reference the values of the array:
foreach ($things as &$thing) { $thing = strtolower($thing); }
It’s a small difference, but it comes in handy once in a while, especially when you’re doing more significant processing with each item.
0 Comments until now.
Comment!