<html>
<head></head>
<body>
My favourite bands are:
<ul>
<?php
// define arrays
$morebands = array('Desturbed', 'Anthrax');
$artists = array('Metallica', 'Evanescence', 'Linkin Park', 'Guns n Roses', "$morebands");
// loop over it
// print array elements
foreach ($artists as $a) {
if ($a != 'Array'){
echo '<li>'.$a;
}
Else {
foreach ("${$a}" as $b){
echo '<li>'.$b;
}
}
}
?>
</ul>
</body>
</html>
I can not figure out why this will not work:(
I would like the foreach to run through the array as normal, but if it encounters a nested array, loop it as well.
I know this likely is not the right, or best way to do this, but I am just learning PHP through a tutorial and I learn best by doing... So I take the lessons, make them more complicated, then figure out how to make it happen (like so).
right now I am working on
http://devzone.zend.com/node/view/id/635
anyhow thanks for any help!