I always used to use foreach in php, but now I’ve swapped to using collection methods in Laravel as they are much more powerful and you can chain them together instead of having multiple loops or nested loops.
Here is an example of map, taken from the docs, which I use a lot
I always used to use foreach in php, but now I’ve swapped to using collection methods in Laravel as they are much more powerful and you can chain them together instead of having multiple loops or nested loops.
Here is an example of map, taken from the docs, which I use a lot