Love the video, thanks Matt! I tend to like using $carry[$name] ??= [] & $carry[$name][$key] ??= 0 just to clean things up, but obviously that's a personal preference. :)
First before making code look more elegant I'll use $name = isset( $item['name'] ) ? $item['name'] : null; if ( is_null( $name ) ) continue; or do something else, but assuming 'name' index is always present is ask for a NOTICE
Hi @Matt Cool explanation after edit video, suggesttion by Titan. it could put more value to video if you add Big (O) value of your function. or in simple word it's space 🚀 and time ⌛ complexity.
It's a couple of years since I've used PHP, but can't you simply do `$carry[$name][$key] += $val` (i.e. without initialising it) relying on it adding $val to nothing or maybe `$carry[$name][$key] = ($carry[$name][$key] ?: 0) + $val` to be a little safer?
Your second one definitely works! With the first one, if you try to do += on an undefined key, you'll get an error, so that wouldn't work. Thanks for sharing!!
Nice! Really cool to see it in PHP.
Thanks so much for sharing your original video! It was such a great inspiration!
Great to see you back, Matt!
Thank you so much!!
Thanks for sharing the native version!
My pleasure!
Very nice! Thanks for sharing !
Thanks Mario!
Haven't seen you in a while, great video!
Thanks so much! Great to be back!
Really cool video, Matt!
Thank you my friend!
Love the video, thanks Matt! I tend to like using $carry[$name] ??= [] & $carry[$name][$key] ??= 0 just to clean things up, but obviously that's a personal preference. :)
Great video! I just noticed the typo in the description :)
HA! Nice catch. Thanks!
First before making code look more elegant I'll use $name = isset( $item['name'] ) ? $item['name'] : null; if ( is_null( $name ) ) continue; or do something else, but assuming 'name' index is always present is ask for a NOTICE
And PHP native version is better.
0:20???
Hi @Matt
Cool explanation after edit video, suggesttion by Titan.
it could put more value to video if you add Big (O) value of your function. or in simple word it's space 🚀 and time ⌛ complexity.
It's a couple of years since I've used PHP, but can't you simply do `$carry[$name][$key] += $val` (i.e. without initialising it) relying on it adding $val to nothing or maybe `$carry[$name][$key] = ($carry[$name][$key] ?: 0) + $val` to be a little safer?
Your second one definitely works! With the first one, if you try to do += on an undefined key, you'll get an error, so that wouldn't work.
Thanks for sharing!!
The non Laravel version is easier to read as per usual
😢 Promo>SM!!