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
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:
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
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
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
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.
--
.---
...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
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
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
[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
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 &&
11 matches
Mail list logo