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

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners