I need to find the of index a string in the following array after it has been exploded. So in the example I'd need to find the index for "really". How can I do this?
function explode2D($row_delim, $col_delim, $str) {
return array_map(function ($line) use ($col_delim) {
return explode($col_delim, $line);
}, explode($row_delim, $str));
} // - slick coding by trincot
$string = 'red<~>blue<~>orange[|]yellow<~>purple<~>green[|]really<~>dark<~>brown';
$array = explode2D("[|]", "<~>", $string);
this returns
Array
(
[0] => Array
(
[0] => red
[1] => blue
[2] => orange
)
[1] => Array
(
[0] => yellow
[1] => purple
[2] => green
)
[2] => Array
(
[0] => really
[1] => dark
[2] => brown
)
)
so i tried this
$search = 'really';
$index = array_search($search, $array);
print($index);
nothing :(