spires Posted June 10, 2011 Share Posted June 10, 2011 Hi I'm trying to build a system that will allow me to too for a sting with in a string. But, in any order. E.G: hire bartender Will bring back - hire bartender - hire a bartender - bartender hire - bartender for hire - hire bartenders - hire a bartenders - bartenders hire - bartenders for hire Currently, it only returns: - hire bartender - hire bartenders Any ideas? $key = $_POST['key']; $ad = $_POST['ad']; $expKey = explode("<br />", nl2br($key)); $expAd = explode("<br />", nl2br($ad)); foreach($expAd as $expAds){ foreach($expKey as $expKeys){ if(strstr($expKeys, $expAds)){ $keyList .= $expKeys; } } $keyList .= "\n"; } Quote Link to comment Share on other sites More sharing options...
spires Posted June 10, 2011 Author Share Posted June 10, 2011 ok solved it. Here is the answer for anyone how wants to know: Basically, had to separate all the words and look one by one. $key = $_POST['key']; $ad = $_POST['ad']; $expKey = explode("<br />", nl2br($key)); $expAd = explode("<br />", nl2br($ad)); $a=0; foreach($expAd as $expAds){ $expAd2 = explode(" ", $expAds); $b=0; foreach($expKey as $expKeys){ $expKey2 = explode(" ", $expKeys); for($c=0;$c<count($expKey2);$c++){ if(strpos($expKey2[$c], $expAd2[$a])){ $keyList .= $expKeys; } } $b++; } $keyList .= "\n"; $a++; } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.