3v4l.org

run code in 300+ PHP versions simultaneously
<?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; } } print_r($out); $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; } } }
Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.24 - 5.5.35, 5.6.8 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.10, 7.2.0 - 7.2.33, 7.3.12 - 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
Array ( [0] => This [1] => test [2] => That [3] => game [4] => awesome [5] => Cristiano [6] => Ronaldo [7] => great [8] => Soccer [9] => Player )
Output for 4.4.5 - 4.4.9
Array ( [0] => This [1] => test [2] => That [3] => game [4] => awesome [5] => Cristiano [6] => Ronaldo [7] => great [8] => Soccer [9] => Player ) Fatal error: Call to undefined function: stripos() in /in/2d0Li on line 42
Process exited with code 255.
Output for 4.3.2 - 4.3.11, 4.4.0 - 4.4.4
Array ( [0] => This [1] => test [2] => That [3] => game [4] => awesome [5] => Cristiano [6] => Ronaldo [7] => great [8] => Soccer [9] => Player ) Fatal error: Call to undefined function: stripos() in /in/2d0Li on line 42
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Array ( [0] => This [1] => test [2] => That [3] => game [4] => awesome [5] => Cristiano [6] => Ronaldo [7] => great [8] => Soccer [9] => Player ) Fatal error: Call to undefined function: stripos() in /in/2d0Li on line 42

preferences:
203.53 ms | 402 KiB | 313 Q