A better way?
Posted: Thu May 24, 2007 10:51 am
feyd | Please use
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
The code below works just fine. Its job is to return the multiple abbreviations which are separated by spaces and stored in a row in my db. They are renamed and then displayed.
My question is, is there a better way to do this than a big elseif statement?
Regards,
PeterCode: Select all
$a=explode(' ',$row['project_type']);
foreach ($a as $key=>$value){
if ($value=="CRG"){$category="City + Region ";}
elseif ($value=="CIV"){$category="Civic ";}
elseif ($value=="CMU"){$category="Commercial + Mixed Use ";}
elseif($value=="ER"){$category="Eco Resorts ";}
elseif ($value=="EDU"){$category="Education ";}
elseif ($value=="POS"){$category="Parks + Open Spaces ";}
elseif ($value=="PAS"){$category="Plazas + Streetscapes ";}
elseif ($value=="SL"){$category="Senior Living ";}
elseif ($value=="TRA"){$category="Transportation ";}
elseif ($value=="WTR"){$category="Waterfronts ";}
echo $category;
}feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]