Finding Similar Or Alike Keywords From String PHP

2019-09-05 21:21发布

问题:

Case 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';
    }
}` 

What I Want In Return : "flash-new" Tag From $tags Array

Case 2 :

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

Return I Want : develop

Case 3 :

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

Return I want : stack overflow

标签: php substring