Jump to content

strpos/stristr/strstr not returning true when they should be


Go to solution Solved by Jessica,

Recommended Posts

I've tried all 3 functions and I can't get it to return true when I clearly see what I'm looking for in the string. 

$string='<div class="lupin lumi1" style="background:url(\'/images/grey_pins2.png\') no-repeat 0 -70px;height:35px;overflow:hidden;width:19px"><a href="http://maps.google.com/maps?hl=en-US&gl=US&safe=0&client=firefox&rls=org.mozilla:en-US:official&num=10&filter=1&complete=0&pws=0&um=1&ie=UTF-8&q=back+pain+austin&fb=1&gl=us&hq=back+pain&am';
	
	
if (strpos($string, "/images/grey_pins" !== FALSE))
	print 'found';
else
	print 'not found';
  • Solution

You have your parentheses messed up.

 

(strpos($string, "/images/grey_pins" !== FALSE))
Is passing strpos two arguments, first is: $string, second is: "/images/grey_pins" !== FALSE

 

Fix your parens and it should work.

Edited by Jessica
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.