Re: IF statement question...
| From: | Tristan dot Pretty at risk dot sungard dot com | Date: | Wed, 19 May 2004 14:47:00 +0000 |
| Subject: | Re: IF statement question... | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-186536@lists.php.net to get a copy of this message | ||
If I'm being Dumb, I apologies...
but When using this:
$row[bands] = "1,2,3,4,5,6,7,8";
$row2[id] = "7";
if (strpos($row[bands], $row2[id]) != FALSE) {
// do stuff
}
I get the No 13 (as it's inthe 13th place in the string) as my result.
Now I'm aware that it should work, as it's not returning a false value...
But I'm still not getting the correct output on my page...
Any other ideas?
Oliver Hankeln <oha@walter-interactive.de>
19/05/2004 15:49
To
php-general@lists.php.net
cc
Subject
Re: [PHP] IF statement question...
Curt Zirzow wrote:
> * Thus wrote Oliver Hankeln (oha@walter-interactive.de):
>>100000 Searches in a rather small string took
>>0.38s with strpos() and 0.55s with preg_match()
>
> Make sure your benchmarks aren't bias:
> - assignment takes time
> - concating string takes time
You are right. I updated the script to:
[...]
$regexp="/".$needle."/";
$t1=getmicrotime();
for($i=0;$i<100000;$i++)
strpos($haystack,$needle);
$t2=getmicrotime();
for($i=0;$i<100000;$i++)
preg_match($regexp,$haystack);
$t3=getmicrotime();
[...]
Now the time is 0.33s vs. 0.46s.
preg_match needs 139.4% of the strpos time
Oliver
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
*********************************************************************
The information contained in this e-mail message is intended only for
the personal and confidential use of the recipient(s) named above.
If the reader of this message is not the intended recipient or an agent
responsible for delivering it to the intended recipient, you are hereby
notified that you have received this document in error and that any
review, dissemination, distribution, or copying of this message is
strictly prohibited. If you have received this communication in error,
please notify us immediately by e-mail, and delete the original message.
***********************************************************************