On Mon, June 26, 2006 1:23 pm, Robert Cummings wrote:
> I can't think of any language that processes the contents of a
> conditional block when the test condition fails.
I believe that PHP with Runkit would let you set that up to happen, if
it was something you actually wanted... :-)
And Common L
On Monday 26 June 2006 13:10, Alex Major wrote:
> Hi list.
> Basically, I'm still learning new things about php and I was wondering if
> things inside an if statement get 'looked at' by a script if the condition
> is false.
> For example, would this mysql query get executed if $number = 0 ?
>
> If
On Mon, 2006-06-26 at 14:10, Alex Major wrote:
> Hi list.
> Basically, I'm still learning new things about php and I was wondering if
> things inside an if statement get 'looked at' by a script if the condition
> is false.
> For example, would this mysql query get executed if $number = 0 ?
>
> If
On Mon, 26 Jun 2006 19:10:59 +0100, Alex Major <[EMAIL PROTECTED]> wrote:
> Hi list.
> Basically, I'm still learning new things about php and I was wondering if
> things inside an if statement get 'looked at' by a script if the condition
> is false.
> For example, would this mysql query get execut
* Thus wrote Jay Blanchard ([EMAIL PROTECTED]):
> [snip]
> strpos() : 0.19018315076828
> preg_match() : 0.26157474517822
> in_array() : 0.26403407096863
> [/snip]
>
> Very interesting...thanks!
>
So if we're not going to search though a string 10,000 times you'll
save ~0.07139159440994 secon
[snip]
strpos() : 0.19018315076828
preg_match() : 0.26157474517822
in_array() : 0.26403407096863
[/snip]
Very interesting...thanks!
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
John Nichel wrote:
Jay Blanchard wrote:
[snip]
strpos() : 0.18918436765671
preg_match() : 0.26665662288666
[/snip]
1/3rd of a second slowerinteresting. You know what though, my
original assertion is correctalmost any of the regex functions will
work.
Tristan, why not convert the string to a
Jay Blanchard wrote:
[snip]
strpos() : 0.18918436765671
preg_match() : 0.26665662288666
[/snip]
1/3rd of a second slowerinteresting. You know what though, my
original assertion is correctalmost any of the regex functions will
work.
Tristan, why not convert the string to an array and then us
Jay Blanchard wrote:
> [snip]
> strpos() : 0.18918436765671
> preg_match() : 0.26665662288666
> [/snip]
>
> 1/3rd of a second slowerinteresting. You know what though, my
> original assertion is correctalmost any of the regex functions
> will work.
Personally, I prefer using preg_match() 9
> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]
> Sent: 19 May 2004 15:47
>
> 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 stuf
[snip]
strpos() : 0.18918436765671
preg_match() : 0.26665662288666
[/snip]
1/3rd of a second slowerinteresting. You know what though, my
original assertion is correctalmost any of the regex functions will
work.
Tristan, why not convert the string to an array and then use in_array()?
John,
Curt Zirzow wrote:
Make sure your benchmarks aren't bias:
- assignment takes time
- concating string takes time
strpos($haystack,$needle);
v.s.
preg_match($regex,$haystack);
Just for shits and giggles (and because it's a slow work day), the below
script output this...
strpos() : 0.18918
[snip]
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
}
[/snip]
What is the expected output?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http:
re 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 <[EMAIL PROTECTED]>
19/05/2004 15:49
To
[EMAIL PROTECTED]
cc
Subject
Re: [PHP] IF statement question...
Curt Z
Curt Zirzow wrote:
* Thus wrote Oliver Hankeln ([EMAIL PROTECTED]):
10 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
* Thus wrote Oliver Hankeln ([EMAIL PROTECTED]):
> Jay Blanchard wrote:
>
> >[snip]
> >Tipp: Do not use preg_match() if you only want to check if one string
> >is contained in another string. Use strpos() or strstr() instead as they
> >
> >will be faster.
> >[/snip]
> >
> >
> >This brings up a g
Jay Blanchard wrote:
[snip]
Tipp: Do not use preg_match() if you only want to check if one string
is contained in another string. Use strpos() or strstr() instead as they
will be faster.
[/snip]
This brings up a good point. Just exactly how much faster would one be
over another in this small exa
[snip]
Tipp: Do not use preg_match() if you only want to check if one string
is contained in another string. Use strpos() or strstr() instead as they
will be faster.
[/snip]
This brings up a good point. Just exactly how much faster would one be
over another in this small example? How big would
Jay Blanchard wrote:
[snip]
Is it possible to request that a string CONTAINS another string...?
EG:
$string = "1, 2, 3, 7, 8, 9";
if ($string CONTAINS "7") {
// Do stuff
}
[/snip]
Almost any regex function would work here, for instance
$string = "1, 2, 3, 7, 8, 9";
if (preg_match("/7/", $st
> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]
> Sent: 19 May 2004 12:55
>
> Is it possible to request that a string CONTAINS another string...?
>
> EG:
> $string = "1, 2, 3, 7, 8, 9";
> if ($string CONTAINS "7") {
> // Do stuff
> }
if (strpos($st
[EMAIL PROTECTED] wrote:
Is it possible to request that a string CONTAINS another string...?
EG:
$string = "1, 2, 3, 7, 8, 9";
if ($string CONTAINS "7") {
// Do stuff
}
int strpos ( string haystack, string needle [, int offset])
is what you are looking for.
HTH,
Oliver Hankeln
--
PHP Genera
[snip]
Is it possible to request that a string CONTAINS another string...?
EG:
$string = "1, 2, 3, 7, 8, 9";
if ($string CONTAINS "7") {
// Do stuff
}
[/snip]
Almost any regex function would work here, for instance
$string = "1, 2, 3, 7, 8, 9";
if (preg_match("/7/", $string)){ //evaluate
22 matches
Mail list logo