3v4l.org

run code in 300+ PHP versions simultaneously
<?php function recursive_array_search($needle,$haystack) { foreach($haystack as $key=>$value) { $current_key=$key; if($needle===$value OR (is_array($value) && recursive_array_search($needle,$value) !== false)) { return $current_key; } } return false; } $arr = [ 31 => "Pelican", 29 => [ "FErQa" => [ "user_file_name" => "Pelican.jpg", "file_name" => "pelican-006.jpg", "file_path" => "/nas/content/live/mysite/wp-content/uploads/sites/2/ninja-forms/", "file_url" => "http://mysite/wp-content/uploads/sites/ ... an-006.jpg", "complete" => "1", "upload_id" => "19", ] ] ]; var_dump(recursive_array_search("/nas/content/live/mysite/wp-content/uploads/sites/2/ninja-forms/", $arr));
Output for 5.5.24 - 5.5.35, 5.6.8 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
int(29)

preferences:
182.18 ms | 404 KiB | 183 Q