Hmm... Are you sure strpos doesn't work for you? Sure worked for me when I
wanted something like that Otherwise, checkout following:
http://se2.php.net/strings

function instr($needle, $haystack,$case_sensitive=true)
{
return
(($case_sensitive?strpos($needle,$haystack):stripos($needle,$haystack))!==fa
lse);
}
try that, although, that's just from the top of my head, not tested or
anything and it's my pretty bad coding style...

also, take a look at ereg()...
-- 
// DvDmanDT
MSN: [EMAIL PROTECTED]
Mail: [EMAIL PROTECTED]
"Chris W. Parker" <[EMAIL PROTECTED]> skrev i meddelandet
news:[EMAIL PROTECTED]
Hi.

I don't know why but I've had the darndest time trying to find an easy
equivalent of asp's InStr() function in PHP. I know there is
preg_match(), strpos(), and strstr(), but none of them work like I want
them to.

In fact, except for maybe preg_match(), I can't get any of them to work
right.

I want a function that will return true if the string is found, and
false if it is not found.

Like this:*

$needle = "&";
$haystack = "Belle & Sebastian";

if(FoundInString($needle, $haystack))
{
echo "found!";
}
else
{
echo "not found!";
}


Anyone have a function to share?


Thanks,
Chris.


* Anyone catch the Belle & Sebastian show at the Greek Theatre in LA
this past sunday?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to