Re: [PHP] Switch statement Question

2009-01-30 Thread Thodoris
Hi, I have a code snippet here as in the following: //Switch statements between the four options switch($string) { case : $string= NOT book.author='All'; break; default: $string= $string . AND NOT book.author='All'; break; } This code does work, but I am wondering if it is possible in

[PHP] Switch statement Question

2009-01-29 Thread Alice Wei
Hi, I have a code snippet here as in the following: //Switch statements between the four options switch($string) { case : $string= NOT book.author='All'; break; default: $string= $string . AND NOT book.author='All'; break; } This code does work, but I am wondering if it is possible in

RE: [PHP] Switch statement Question

2009-01-29 Thread Boyd, Todd M.
-Original Message- From: Alice Wei [mailto:aj...@alumni.iu.edu] Sent: Thursday, January 29, 2009 3:02 PM To: php-general@lists.php.net Subject: [PHP] Switch statement Question Hi, I have a code snippet here as in the following: //Switch statements between the four options

Re: [PHP] Switch statement Question

2009-01-29 Thread Jochem Maas
Boyd, Todd M. schreef: -Original Message- From: Alice Wei [mailto:aj...@alumni.iu.edu] Sent: Thursday, January 29, 2009 3:02 PM To: php-general@lists.php.net Subject: [PHP] Switch statement Question Hi, I have a code snippet here as in the following: //Switch statements

Re: [PHP] If statement question

2006-06-27 Thread Richard Lynch
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

[PHP] If statement question

2006-06-26 Thread Alex Major
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 ($number == 1) { mysql_query($blah) } I know that's not

Re: [PHP] If statement question

2006-06-26 Thread Martin Marques
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 executed if

Re: [PHP] If statement question

2006-06-26 Thread Robert Cummings
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

Re: [PHP] If statement question

2006-06-26 Thread Larry Garfield
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

[PHP] If statement question...

2004-10-10 Thread GH
I would like to know how I can code the the following conditional check if the $_GET['api'] does not exist, or is either set and has no length or is set and is not an integer. I am drawing a blank on the if statement to use -- PHP General Mailing List (http://www.php.net/) To

[PHP] IF statement question...

2004-05-19 Thread Tristan . Pretty
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 } * The information contained in this e-mail message is intended only for the

RE: [PHP] IF statement question...

2004-05-19 Thread Jay Blanchard
[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)){ //evaluates to

Re: [PHP] IF statement question...

2004-05-19 Thread Oliver Hankeln
[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 General

RE: [PHP] IF statement question...

2004-05-19 Thread Ford, Mike [LSS]
-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($string,

Re: [PHP] IF statement question...

2004-05-19 Thread Oliver Hankeln
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/, $string)){

RE: [PHP] IF statement question...

2004-05-19 Thread Jay Blanchard
[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

Re: [PHP] IF statement question...

2004-05-19 Thread Oliver Hankeln
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

Re: [PHP] IF statement question...

2004-05-19 Thread Curt Zirzow
* 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 good point. Just

Re: [PHP] IF statement question...

2004-05-19 Thread Oliver Hankeln
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

Re: [PHP] IF statement question...

2004-05-19 Thread Tristan . Pretty
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 Zirzow wrote: * Thus wrote Oliver Hankeln ([EMAIL PROTECTED

RE: [PHP] IF statement question...

2004-05-19 Thread Jay Blanchard
[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:

Re: [PHP] IF statement question...

2004-05-19 Thread John Nichel
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() :

RE: [PHP] IF statement question...

2004-05-19 Thread Jay Blanchard
[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()?

RE: [PHP] IF statement question...

2004-05-19 Thread Ford, Mike [LSS]
-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 stuff } I get

RE: [PHP] IF statement question...

2004-05-19 Thread Michael Sims
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 times

Re: [PHP] IF statement question...

2004-05-19 Thread John Nichel
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

Re: [PHP] IF statement question...

2004-05-19 Thread John Nichel
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

RE: [PHP] IF statement question...

2004-05-19 Thread Jay Blanchard
[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

Re: [PHP] IF statement question...

2004-05-19 Thread Curt Zirzow
* 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 seconds. or

[PHP] switch statement question

2002-08-13 Thread Alexander Ross
Say i have a variable $string_var = Once upon a time; is there a way to do this: Switch($string_var) { case(contains Once): doSomething(); break; case(contains the end.) doOtherThing(); break; case(contains time) doNothing(); break; default: echo ERROR } Thanks

RE: [PHP] switch statement question

2002-08-13 Thread Jay Blanchard
[snip] Say i have a variable $string_var = Once upon a time; is there a way to do this: Switch($string_var) { case(contains Once): doSomething(); break; case(contains the end.) doOtherThing(); break; case(contains time) doNothing(); break; default: echo ERROR }

Re: [PHP] switch statement question

2002-08-13 Thread DL Neil
Alternatively Alexander, take a look at the string functions eg strstr(), stristr(), and strpos() all of which can be used to make a condition within the case() criteria. Regards, =dn [snip] Say i have a variable $string_var = Once upon a time; is there a way to do this:

RE: [PHP] selcet statement question

2002-07-26 Thread Jay Blanchard
[snip] I know that i can retrieve records 1-24 in my db with a select statement like SELECT whatever FROM tablename ORDER BY id ASC LIMIT 23, but how can I get records 25 to 50 if I have 100 records in my DB? [/snip] Different DB's have differing ways of doing this, like MySQL; SELECT * FROM