3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $str="This is a test - That game is awesome (Cristiano Ronaldo is a great Soccer Player)"; //clean string: $str=preg_replace("/[^A-Za-z0-9 ]/", '', $str); //first explode it $e=explode(' ',$str); //loop to remove short words $out=array(); foreach ($e as $a){ if(strlen($a)>2){ $out[]=$a; } } $list = array( "This" => "9", "great" => "10", "God Father" => "11", "Tony Montana" => "12", "Ronaldo" => "13", "Al Pacino" => "14", "Humans" => "15", "Play" => "16" ); foreach ($out as $keyword) { foreach ($list as $word=>$num) { $sim_chars = similar_text($keyword, $word); if ($sim_chars/strlen($keyword) > .8 || $sim_chars/strlen($word) > .8) { $all_key_values[] = $num; $all_keys[] = $word; } elseif (stripos($keyword, $word) !== false || strpos($word, $keyword) !== false) { $sll_key_values[] = $num; $all_keys[] = $word; } } } print_r(implode(',', $all_key_values)); print_r(implode(',', $all_keys));
Output for 5.0.0 - 5.6.28, hhvm-3.12.0, 7.0.0 - 7.1.0
9,13,10,16This,Ronaldo,great,Play
Output for hhvm-3.10.0

Process exited with code 153.
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: stripos() in /in/7avNv on line 41
Process exited with code 255.
Output for 4.3.2 - 4.4.4
Fatal error: Call to undefined function: stripos() in /in/7avNv on line 41
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Call to undefined function: stripos() in /in/7avNv on line 41