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; } } $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 git.master, git.master_jit, rfc.property-hooks
9,13,10,16This,Ronaldo,great,Play

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
43.02 ms | 401 KiB | 8 Q