I have an array with title and children index.
title
children
title is always not-null. children is an array, empty or not-empt
I'm sure this will work :
function menu($arr) { echo ""; foreach ($arr as $val) { if (!empty($val['children'])) { echo "" . $val['title']; menu($val['children']); echo ""; } else { echo "" . $val['title'] . ""; } } echo ""; }