Page 1 of 1

how to search a string

Posted: Tue Dec 16, 2008 12:25 am
by zerandib
Hello,

I need to search for a specific string,

like this;

$variable1 = "this is the available text. it has a url named http://www.myurl.com/val=12&id=001 and it has more more sentences as well."

what i wants to do is to search for the string "http://www.myurl.com/" and if that available in $variable1, needs to print "ok"

if( ..?.. )
{
echo "ok";
}


need help!

Re: how to search a string

Posted: Tue Dec 16, 2008 12:30 am
by cavemaneca

Re: how to search a string

Posted: Tue Dec 16, 2008 10:19 am
by pickle
strpos() is faster.

Re: how to search a string

Posted: Fri Dec 19, 2008 12:46 pm
by novice4eva
pickle wrote:strpos() is faster.
I read strstr() was faster, i bet that it was given in bold letter in old php manual somewhere :D , it's not there in the latest one !!

Code: Select all

http://www.php.net/strstr
there is the post that suggests the same, by Romuald Brunet. Anyways as i said, i just read it and haven't really checked it, and even if it were, i bet the time diff won't be that significant