Jump to content

string with in a string?


spires

Recommended Posts

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";
 }

Link to comment
https://forums.phpfreaks.com/topic/239015-string-with-in-a-string/
Share on other sites

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++;
 }

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.