3v4l.org

run code in 200+ 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'); $all_key_values = $all_keys = 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) { $all_key_values[] = $num; $all_keys[] = $word; } elseif (strpos($keyword, $word) !== false || strpos($word, $keyword)) { $sll_key_values[] = $num; $all_keys[] = $word; } } } print_r($all_key_values); print_r($all_keys);
Output for 4.3.0 - 7.2.0
Array ( [0] => 9 [1] => 11 [2] => 16 [3] => 12 ) Array ( [0] => Data [1] => Database [2] => Technology [3] => Creativity )