View Single Post

  #3 (permalink)  
Old 03-24-2007
Kim André Akerĝ
 
Posts: n/a
Default Re: There's got to be a better way

Mary Pegg wrote:

> There's got to be a better way:
> if (isset($c['s']['a1'])) echo $c['s']['a1']."<br>";
> if (isset($c['s']['a2'])) echo $c['s']['a2']."<br>";
> if (isset($c['s']['a3'])) echo $c['s']['a3']."<br>";
> if (isset($c['s']['a4'])) echo $c['s']['a4']."<br>";
> if (isset($c['s']['a5'])) echo $c['s']['a5']."<br>";
>
> but it's late and my brain is frazzled. Any ideas, oh PHP gurus?


Perhaps like this?

foreach ($c['s'] as $item) {
echo $item."<br>";
}

If you want an extra check, you could also surround it with this:
if (isset($c['s']) and is_array($c['s'])) {
}

--
Kim André Akerĝ
- kimandre@NOSPAMbetadome.com
(remove NOSPAM to contact me directly)
Reply With Quote