私はここに、いくつかの研究を行ってきたが、あなたがそれを行うことの方法です:
$array = array(0 => 'blue', 1 => 'reds', 2 => 'green', 3 => 'reds');
//Words to be searched from.
$res = array("percent" => "0", "word" => "N/A");
//Result, this is an array for the bellow loop to talk to.
foreach($array AS $ar){
similar_text("red", $ar, $percent);
//If it's more like the word, then replace the percentage with the percentage of similarity & word.
if($percent > $res["percent"]){
$res["percent"] = $percent;
$res["word"] = $ar;
}
}
//Echo out the most similar word.
echo $res["word"];
私が見つけることができるものから、これは可能な唯一の方法でしたこのようなことをするために。
私はそうする可能性があるとは思わない。 – FluxCoder
@FluxCoderそれでは、 'php'が動くことをどのように提案するのですか – Achmed
そして、あなたは「最も類似」をどれくらい正確に定義していますか? –