General

PHP multi-dimensional arrays and array_column

Instead of implementing your own multi-level array search, be sure to take advantage of the functions already in the language.

Specifically array_column. It’s an easy way to search the columns of a specific multi-dimensional array or an array of objects. Highly useful and much more readable than double loops.

Examples:
Instead of looping through like this.

for($i = 0; $i < 10; $i++) {
   if($multiArray[$i]['myColumn'] = $searchCriteria) {
      return $foundItem;
   }
}

try


$found = array_search($searchCriteria, array_column($multiArray, "myColumn"));

There is a little better code clarity here, I think. Typically speaking, native functions will also perform better. You also reduce the need to create your own functions, tests, etc...

h/t Stackoverflow