Re: There's got to be a better way



Mary Pegg pravi:
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?


Dunno about php but i think theoreticaly this should work:

$counter = 1
while $count < 6 do {
if (isset($c['s']['a.$counter'])) echo $c['s']['a$counter']."<br>";

$counter++;
}



regards,
.



Relevant Pages