Konstruktionsplan
1 month ago
362
6
Guides

Deep dark forest 🌲

Posted 1 month ago by Konstruktionsplan
function capMe($arr) {
  foreach ($arr as &$item) {
    $item = ucwords(strtolower($item));
  }
  return $arr;
}

This function transforms every first letter of the item in the array to a capital letter. (But it also makes them small in the first place).

I got that.

But I just do not understand what exactly makes:

&$item

"Parameter passing by reference" says Google. Could somebody explain it in a way that it also understands 🐒? Maybe with more, practical, examples? The more, the better!

Thanks! 💜

Please sign in or create an account to participate in this conversation.