Re: String eval assistance
| From: | Daniel Brown | Date: | Tue, 15 Mar 2011 21:47:56 +0000 |
| Subject: | Re: String eval assistance | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-311880@lists.php.net to get a copy of this message | ||
On Tue, Mar 15, 2011 at 17:34, Jack <JackListMail@gmail.com> wrote:
> Hello All,
>
>
>
> I got some help on this yesterday, but somehow it's not consistant
>
>
>
> <?
For compatibility, you shouldn't use short_open_tags.
> $results = "3434approd34";
Here you're defining the variable as a string.
> if(strpos($results['response'], 'APPROVED') !== false) {
Here you're trying to access it as an array, which it's not, so
the 'response' key doesn't exist. In addition, you're looking for
UPPER-CASE, whereas that's not the case in your example variable.
Finally, you're checking to make sure that the string IS INDEED found,
but then printing that it was declined (!== false). Instead, you may
want:
<?php
$results['response'] = '3434approd34';
if (stripos($results['response'],'APPROVED') !== false) {
// It's been found
} else {
// Oh, crap.
}
?>
--
</Daniel P. Brown>
Network Infrastructure Manager
http://www.php.net/