function subs($items, $id, $count) { $count++; foreach ($items as $item) { if ($item['parent'] == $id) { echo "<option value=" . $item['id'] . ">"; for ($i = 0; $i < $count; $i++) { echo " - "; } echo $item['title'] . "</option>"; subs($items, $item['id'], $count); } } }
function subs($items, $id, $count) { $count++; foreach ($items as $item) { if ($item['parent'] == $id) { echo "<option value='" . $item['id'] . "'"; //echo " ".()? 'selected="selected"':''; if ($GLOBALS['parent'] == $item['id']) { echo 'selected=selected'; } //echo $GLOBALS['parent']; echo ">"; for ($i = 0; $i < $count; $i++) { echo " - "; } echo $item['title'] . "</option>"; subs($items, $item['id'], $count); } } }