- htmlentities: documentation ( source)
- asort: documentation ( source)
<?php
$mylist = array("thing1" => "Balloon", "thing2" => "Cat", "thing3" => "Egg", "thing4" => "Dog", "thing5" => "Apple");
asort($mylist);
foreach($mylist as $id => $value) {
$id = htmlentities($id, ENT_QUOTES);
$value = htmlentities($value);
echo "<div id='{$id}'>{$value}</div>";
}