I have an array of arrays and I want to copy the first column
The data looks like this:
(0 => "homer", 1 => 1, 2 => 2, 3 => 3)
(0 => "marge", 1 => 2, 2 => 4, 3 => 8)
(0 => "bart", 1 => 6, 2 => 2, 3 => 7)
(0 => "lisa", 1 => 16, 2 => 20, 3 => 71)
Is there a PHP function (similar to array_search) which I can use to search for a name match in the first "column" ?
The data in the first column is already sorted so if I could copy "column1", I could carry out a array_search (which I assume uses a bsearch, rather than a naive element by element iteration).
My questions are:
Is there a PHP function similar to array_search, which I can use to search for matching items in the 1st column of the 2D array?
Failing that, is there a PHP function to copy the first column into a 1D array (whilst preserving order) so I can call array_search on it ?