3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ [ 'name' => 'Dick Jansen', 'matchedMovie' => [ [ 'nameMovie' => 'Saw', 'genre' => 'Horror', 'patheMovie' => 'Texas Chainsaw 3D', 'patheMovieGenre' => 'Horror', 'score' => '100.00', ] ] ], [ 'name' => 'Jim Scott', 'matchedMovie' => [ [ 'nameMovie' => 'Shooter', 'genre' => 'Action, Thriller', 'patheMovie' => 'The Shining', 'patheMovieGenre' => 'Horror, Suspense/Thriller', 'score' => '52.38', ], [ 'nameMovie' => 'Resident Evil Movie', 'genre' => 'Action/Horror', 'patheMovie' => 'Texas Chainsaw 3D', 'patheMovieGenre' => 'Horror', 'score' => '63.16', ] ] ] ]; function findMovieMatches(array $movies, string $movieName): array { $result = []; foreach ($movies as ['name' => $name, 'matchedMovie' => $matches]) { foreach ($matches as $entry) { if ($movieName === $entry['patheMovie']) { $result[] = ['name' => $name] + $entry; } } } return $result; } var_export(findMovieMatches($array, 'Texas Chainsaw 3D')); echo "\n---\n"; var_export(findMovieMatches($array, 'The Shining'));
Output for 8.0.1 - 8.0.30, 8.1.0 - 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.29, 8.4.1 - 8.4.14, 8.4.16, 8.5.0 - 8.5.1
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', ), ) --- array ( 0 => array ( 'name' => 'Jim Scott', 'nameMovie' => 'Shooter', 'genre' => 'Action, Thriller', 'patheMovie' => 'The Shining', 'patheMovieGenre' => 'Horror, Suspense/Thriller', 'score' => '52.38', ), )
Output for 8.4.15
/bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15)
Process exited with code 1.

preferences:
151.99 ms | 408 KiB | 5 Q