| 
	
 | 
 Posted by Ric on 12/20/06 20:11 
Els schrieb: 
> Hi all, 
>  
> Sorry for the bad subject line, I wouldn't know how to describe this. 
> I'm sure this is common knowledge for anyone who knows PHP, i.e. not 
> me, but I can't find the answer online.  
>  
> I'm just looking for a way to write the following in a shorter way: 
> if ($a == 1 || $a == 2 || $a == 3 || $a == 4 || $a == 17 || $a == 30) 
>  
> Something that equates to "if $a == one of ((1 - 4), 17, 30)"  
>  
> TIA, 
>  
Just for the record: 
 
$num = array(1=>1,2=>1,3=>1,10=>1); 
$a=10; 
if(isset($num[$a])){ 
echo "Ain't that cool"; 
}
 
  
Navigation:
[Reply to this message] 
 |