Re: String eval assistance

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 16/03/2011, at 10:34 AM, Jack wrote:

> Hello All,
> 
> 
> 
> I got some help on this yesterday, but somehow it's not consistant
> 
> 
> 
> <?
> 
> 
> 
> $results = "3434approd34";
> 
> 
> 
> if(strpos($results['response'], 'APPROVED') !== false) {
> 
> 
> 
>   print "declined";
> 
> 
> 
> } else {
> 
> 
> 
>   print "approved";
> 
> }
> 
> 
> 
> ?>
> 
> 
> 
> 
> 
> The thing is I cant get a consistant response, if it has approved anywhere
> in the results string, then it should be approved and if the results is
> APPROVD without the E it shold be delined.
> 
> 
> 
> Am I doing something wrong.
> 
> 
> 
> 
> 
> Thanks!
> 
> Jack

Yes, you're doing something wrong. strpos() returns false if it can't find the needle. You should be using if(strpos() === false) { declined; }
---
Simon Welsh
Admin of http://simon.geek.nz/

Who said Microsoft never created a bug-free program? The blue screen never, ever crashes!

http://www.thinkgeek.com/brain/gimme.cgi?wid=81d520e5e


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




[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux