Category: PHP

During my time working in PHP, I have often found my self needing to search for a matching row in a multi-dimensional array but found that the built in functions of PHP a bit lacking, until I found this solution. Say we have a multi-dimensional array like this The way to search a 1d array would be to use the function array_search(‘foo’, $array) but as you may see this doesn't work with a 2d array. To solve this in the past I would have written a function like so Which does work but writing your own search function for every project that requires it, is not the greatest solution.
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge. Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge.
Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Shirts painstakingly handcrafted by under-caffeinated developers. Shirts painstakingly handcrafted by under-caffeinated developers.
Community Partners