1
我創建了一個輸入文本,我在其中編寫了一些要在數組中搜索的內容。PHP - 搜索類似於字符串的字符串
我已經使用stristr()和stripos函數(),但白衣這個我只得到了同樣的話,例如:
<?php
$value[0]= 'animals';
//other array values
$arrayResp = [];
foreach($valuefounded as $value)
{
if(stristr($value, "animals") !== FALSE)
{
$arrayResp[]= $value;
}
}
我怎麼能得到同樣的結果,如果我輸入的語法錯誤,如「animls」
研究 「[Levenshtein距離](https://www.google.com/search?q=levenshtein+distance&oq=levinstein+d&aqs=chrome.1.69i57j0l5.4394j0j7&sourceid=chrome&ie=UTF-8)」 和[PHP的levenshtein()函數](http://php.net/manual/en/function.levenshtein.php) – TecBrat
我不知道該項目的範圍或大小,但Lucene的,SOLR,elasticsearch是偉大的。但它是一個安裝和學習曲線,所以不知道它是否值得爲您服務。 – Nic3500
感謝您的回答,但對於我的項目,Levenshtein()已經足夠好了。 –