I have this array:
Array
(
[0] => Array
(
[name] => Dick Jansen
[matchedMovie] => Array
(
[0] => Array
(
[nameMovie] => Saw
[genre] => Horror
[patheMovie] => Texas Chainsaw 3D
[patheMovieGenre] => Horror
[score] => 100.00
)
)
)
[1] => Array
(
[name] => Jim Scott
[matchedMovie] => Array
(
[0] => Array
(
[nameMovie] => Shooter
[genre] => Action, Thriller
[patheMovie] => The Shining
[patheMovieGenre] => Horror, Suspense/Thriller
[score] => 52.38
)
[1] => Array
(
[nameMovie] => Resident Evil Movie
[genre] => Action/Horror
[patheMovie] => Texas Chainsaw 3D
[patheMovieGenre] => Horror
[score] => 63.16
)
)
)
)
I want to search on a [patheMovie] value (like 'The Shining') and get the parent array with the [name] plus only the [matchedMovie] array with the matched [patheMovie] back.
I tried something like this:
$search='Texas Chainsaw 3D';
$sorted=false;
foreach ($sorted as $n=>$c)
if (in_array($search,$c)) {
$cluster=$n;
break;
}
if i search for 'The Shining' for example i want the array to return like this:
Array
(
[0] => Array
(
[name] => Dick Jansen
[nameMovie] => Saw
[genre] => Horror
[patheMovie] => Texas Chainsaw 3D
[patheMovieGenre] => Horror
[score] => 100.00
)
)
and if you search for 'Texas Chainsaw 3D' like so:
Array
(
[0] => Array
(
[name] => Dick Jansen
[nameMovie] => Saw
[genre] => Horror
[patheMovie] => Texas Chainsaw 3D
[patheMovieGenre] => Horror
[score] => 100.00
)
[1] => Array
(
[name] => Jim Scott
[nameMovie] => Resident Evil Movie
[genre] => Action/Horror
[patheMovie] => Texas Chainsaw 3D
[patheMovieGenre] => Horror
[score] => 63.16
)
)