3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $input_arr= array( 0=>array("india0","srilanka1","pakistan0","banglades0"), 1=>array("india1","srilanka1","pakistan1","bangladesh1"), 2=>array("india2","srilanka2","pakistan2","bangladesh2"), 3=>array("india3","srilanka3","pakistan3","bangladesh3"), 4=>array("india 4","srilanka4","pakistan4","bangladesh4"), 5=>array("india 5","srilanka5","pakistan5","bangladesh5"), ); $first_str = "pakistan2"; $second_str = "bangladesh4"; $arr_output = array(); foreach($input_arr as $key=>$temp_arr) { if(in_array($first_str, $temp_arr) || in_array($second_str, $temp_arr) ) { $arr_output[$key]=$temp_arr; } } print_r($arr_output);
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
Array ( [2] => Array ( [0] => india2 [1] => srilanka2 [2] => pakistan2 [3] => bangladesh2 ) [4] => Array ( [0] => india 4 [1] => srilanka4 [2] => pakistan4 [3] => bangladesh4 ) )