从字符串PHP中查找类似或类似的关键字

时间:2016-05-11 16:03:29

标签: php substring

案例1:

$tofind= "The Flash Tv Show";
$tags= array("flash-new","netflix","article","season");
foreach ($tags as $key => $tag)
{  
    if (preg_match("/$tofind/",$tag))
    {
      echo 'true';
    }
    else
    {
        echo'false';
    }
}` 

我想要的回报:" flash-new"标记来自$ tags数组

案例2:

$tofind = "PHP Development Artice";
$array = array("java","develop","post");

返回我想要:开发

案例3:

$tofind = "StackOverflow Questions";
$array = array("stack Overflow","sql","php");

返回我想:堆栈溢出

0 个答案:

没有答案