Re: String eval assistance

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

 



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@xxxxxxxxx> wrote:

On 16 March 2011 00:25, Jack <JackListMail@xxxxxxxxx> 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 


[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