私はこの配列を持っています:
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
)
)
)
)
[patheMovie] 値 (「The Shining」など) を検索し、[name] を持つ親配列と、一致した [patheMovie] を持つ [matchedMovie] 配列のみを取得したいと考えています。
私はこのようなことを試しました:
$search='Texas Chainsaw 3D';
$sorted=false;
foreach ($sorted as $n=>$c)
if (in_array($search,$c)) {
$cluster=$n;
break;
}
たとえば、「The Shining」を検索すると、配列が次のように返されます。
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
)
)