3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $list = array( "Data" => "9", "Data Structure" => "10", "Database" => "11", "Creativity" => "12", "Forest" => "13", "Al Pacino" => "14", "Humans" => "15", "Technology" => "16" ); $post = array ('Database', 'Law', 'Tech', 'Creative'); $matches = array(); foreach ($post as $keyword) { foreach ($list as $word=>$num) { $sim_chars = similar_text($keyword, $word); if ($sim_chars/strlen($keyword) > .8 || $sim_chars/strlen($word) > .8) { $matches[] = $num; } } } print_r($matches);
Output for 4.3.0 - 7.1.0
Array ( [0] => 9 [1] => 11 [2] => 16 [3] => 12 )