Here's a much more convenient way to do this than the html echo ...
<ul> <?php foreach( $array as $city => $hotels ): ?> <li><?= $city ?> <ul> <?php foreach( $hotels as $hotel ): ?> <li><?= $hotel ?></li> <?php endforeach; ?> </ul> </li> <?php endforeach; ?> </ul>
Here's another way to use h2s for cities and non-nested lists
<?php foreach( $array as $city => $hotels ): ?> <h2><?= $city ?></h2> <ul> <?php foreach( $hotels as $hotel ): ?> <li><?= $hotel ?></li> <?php endforeach; ?> </ul> <?php endforeach; ?>
The output html is not in the best format, but you can fix it. It's all about whether you want pretty html or easier to read code. It's easier for me to read the code =)
Galen
source share