Chris,

Ive modified your sample code to use strstr() and it works fine. maybe you've mixed 
the $haystack and $needle around ?

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

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

> -----Original Message-----
> From: Chris W. Parker [mailto:[EMAIL PROTECTED]
> Sent: Thursday, 28 August 2003 07:08
> To: [EMAIL PROTECTED]
> Subject: [PHP] php equivalent to asp's instr()
> 
> 
> 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
> 
> 


*************************************************************************************
This e-mail, including any attachments to it, may contain confidential and/or personal 
information.
If you have received this e-mail in error, you must not copy, distribute, or disclose 
it, use or take any action 
based on the information contained within it.

Please notify the sender immediately by return e-mail of the error and then delete the 
original e-mail.

The information contained within this e-mail may be solely the opinion of the sender 
and may not necessarily 
reflect the position, beliefs or opinions of Salmat on any issue.

This email has been swept for the presence of computer viruses known to Salmat's 
anti-virus systems.

For more information, visit our website at  www.salmat.com.au.
*************************************************************************************

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

Reply via email to