<?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.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.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 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
- 9,13,10,16This,Ronaldo,great,Play
- 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.3.11, 4.4.0 - 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
preferences:
312.21 ms | 401 KiB | 460 Q