I\'m trying to search for a value in a multi dimensional array (below is only a part of the big array) and get the key for that value but I can\'t manage it by myself. Here is w
If you don't need to key, you could use array_filter
$result = array_filter($data, function($item) use ($search) {
return $item[8] == $search;
})[0];
If you need the key, you could modify it like this
$key = false;
$result = array_filter($data, function($item, $k) use ($search, &$key) {
if ($item[8] == $search) {
$key = $k;
return true;
}
return false;
}, ARRAY_FILTER_USE_BOTH)[0];
To handle cases, where no result is found, you have to skip the [0] party and test if count($result) != 0