Re: String eval assistance
| From: | Alex | Date: | Wed, 16 Mar 2011 11:44:52 +0000 |
| Subject: | Re: String eval assistance | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-311884@lists.php.net to get a copy of this message | ||
I'm not sure as to why strpos does what it does here, at least its not immediately obvious,
but, a solution to this would be to use a regular expression search, it would be more exact, it has
never failed me, and it will be faster; I recall reading that preg functions were faster at then str
ones, though I can't recall where...
--
Sent from my Android phone with K-9 Mail. Please excuse my brevity.
Richard Quadling <rquadling@gmail.com> wrote:
On 16 March 2011 00:25, Jack <JackListMail@gmail.com> wrote: >> 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. >> } >> >> ?> > >
maybe I should do this some other way because I'm getting false positives. > > I was
using if(strpos($results['response'], 'APPROVED') !== false) { > And its
found if the value of $results = "3434APPROVED34" and it also is > found if its
$results = "3434APPOVED34", so this may not be the best way to > accomplish this. >
> > -- > PHP General Mailing List
(http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > Can you create a
small list of actual values and their results. What version of PHP are you using? -- Richard
Quadling Twitter : EE : Zend @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY -- PHP General
Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php