Switch eregi proglem
Posted: Mon Aug 03, 2009 7:16 am
Hi,
Trying to include an eregi statement in my switch, but doesn't seem to work very well.
I have a unit size column which has for example: 0, 1, 10, 20-30
I want the eregi to recognize the 20-30 and change the $unit_size variable accordingly. Any way I can get this to work within the switch or should I just add an if statement with the eregi before the switch ?
Code: Select all
switch($unit['min_size']) {
case 0:
$unit_size = "<i>You may only include one in your army</i>";
break;
case 1:
$unit_size = "";
break;
case eregi('^[0-9]+-[0-9]+$', $unit['min_size']):
$unit_size = $unit['min_size'];
break;
default:
$unit_size = "Unit Size: {$unit['min_size']}+";
}
I have a unit size column which has for example: 0, 1, 10, 20-30
I want the eregi to recognize the 20-30 and change the $unit_size variable accordingly. Any way I can get this to work within the switch or should I just add an if statement with the eregi before the switch ?