Re: [PHP] Suggestion for "IN()"

2004-10-06 Thread Shawn McKenzie
Your first scenario can been done in a similar fashion to how you are used to doing it in SQL: if ( in_array($a, array(1,4,20,...) ) {} Your second scenario doesn't seem like there is much of a problem because it will always be short (can only have 2 comparisons). -Shawn Jay Blanchard wrote: [s

RE: [PHP] Suggestion for "IN()"

2004-10-01 Thread Ford, Mike
On 01 October 2004 14:05, Daniel Schierbeck wrote: > Jay Blanchard wrote:> > > You could write a function and share it with the rest of us! > > function between ($var, $min, $max) > { > return ($var > $min && $var < $max) ? TRUE : FALSE; } Don't make PHP do more work than it needs to:

Re: [PHP] Suggestion for "IN()"

2004-10-01 Thread Daniel Schierbeck
Christophe Chisogne wrote: Daniel Schierbeck wrote: return ($var > $min && $var < $max) ? TRUE : FALSE; > (...) > return in_array($needle, $haystack) ? TRUE : FALSE; You can return booleans without comparing them to true/false: return $var > $min && $var < $max; return in_array($n

Re: [PHP] Suggestion for "IN()"

2004-10-01 Thread Christophe Chisogne
Daniel Schierbeck wrote: return ($var > $min && $var < $max) ? TRUE : FALSE; > (...) > return in_array($needle, $haystack) ? TRUE : FALSE; You can return booleans without comparing them to true/false: return $var > $min && $var < $max; return in_array($needle, $haystack); Ch

Re: [PHP] Suggestion for "IN()"

2004-10-01 Thread Daniel Schierbeck
Jay Blanchard wrote:> You could write a function and share it with the rest of us! function between ($var, $min, $max) { return ($var > $min && $var < $max) ? TRUE : FALSE; } function in () { if (func_num_args() < 2) trigger_error('You must provide at least one argument for in()', E_USE

Re: [PHP] Suggestion for "IN()"

2004-09-30 Thread Robert Cummings
On Thu, 2004-09-30 at 15:50, Cosmin wrote: > you could try in_array() > > if (in_array(1,2,3,4,5), 6) Just for farts and giggles... possibly better speed with such a basic datatype: if( strpos( ' 1 2 3 4 5 6 7 ', " $a " ) !== false ) Cheers, Rob. -- .---

Re: [PHP] Suggestion for "IN()"

2004-09-30 Thread Cosmin
...sorry, that should have been if (in_array(array(1,2,3,4), 6)) On Thu, 2004-09-30 at 22:10, Daevid Vincent wrote: > I'm sure I'll be flamed for this, but it seems to me that there should be a > shortcut way to write: > > If ($a == 1 || $a == 4 || $a == 20 || ...) {} > > To something more li

Re: [PHP] Suggestion for "IN()"

2004-09-30 Thread Jason Wong
On Friday 01 October 2004 03:10, Daevid Vincent wrote: > I'm sure I'll be flamed for this, but it seems to me that there should be a > shortcut way to write: > > If ($a == 1 || $a == 4 || $a == 20 || ...) {} > > To something more like what SQL has... > > If ( $a IN(1,4,20,...) ) {} in_array() or m

Re: [PHP] Suggestion for "IN()"

2004-09-30 Thread Cosmin
you could try in_array() if (in_array(1,2,3,4,5), 6) On Thu, 2004-09-30 at 22:10, Daevid Vincent wrote: > I'm sure I'll be flamed for this, but it seems to me that there should be a > shortcut way to write: > > If ($a == 1 || $a == 4 || $a == 20 || ...) {} > > To something more like what SQL h

RE: [PHP] Suggestion for "IN()"

2004-09-30 Thread Jay Blanchard
[snip] I'm sure I'll be flamed for this, but it seems to me that there should be a shortcut way to write: If ($a == 1 || $a == 4 || $a == 20 || ...) {} To something more like what SQL has... If ( $a IN(1,4,20,...) ) {} And same with the very helpful SQL BETWEEN 'function'. Instead of If ($a

[PHP] Suggestion for "IN()"

2004-09-30 Thread Daevid Vincent
I'm sure I'll be flamed for this, but it seems to me that there should be a shortcut way to write: If ($a == 1 || $a == 4 || $a == 20 || ...) {} To something more like what SQL has... If ( $a IN(1,4,20,...) ) {} And same with the very helpful SQL BETWEEN 'function'. Instead of If ($a > 1 &&