1
Having problem assigning a multidimensional array to template
my function
le="color: #000000"><?php $catid = (isset($_GET['subcat'])) ? intval($_GET['subcat']) : 0; $subcats_show = showSubcats($catid); print_r($subcats_show); $xoopsTpl->assign('subs', $subcats_show); function showSubcats($catid) { global $xoopsUser, $xoopsConfig, $xoopsDB, $xoopsModuleConfig; $subs = array(); //print $sql."n"; $query = $xoopsDB->query(' SELECT * FROM ' . $xoopsDB->prefix('destinations_topic'). " WHERE topic_pid=".$catid." "); $i =0; while ($row = $xoopsDB->fetchArray($query)) { $subs[$i]['parent']['topic_id'] = $row['topic_id']; $subs[$i]['parent']['topic_title'] = $row['topic_title']; //$categories[$i]['topic_img'] = $row['topic_img']; $child = $row['topic_id']; //print_r($child_array); $topicHandler =& xoops_getModuleHandler('destinations_topic', 'destinations'); $criteria = new Criteria('topic_pid',$child); $arr = $topicHandler->getAll($criteria); $mytree = new XoopsObjectTree($arr, 'topic_id', 'topic_pid'); $child_array = $mytree->getAllChild($child); foreach ($child_array as $child) { $subs[$i]['child']['topic_id'] = $child->getVar('topic_id'); $subs[$i]['child']['topic_title'] = $child->getVar('topic_title'); //$subs['parent'][$i]['child'][$j]['url'] = $url.$child->getVar($id_name); } $i++; } return $subs; }
in print recursive i am getting the array like this
le="color: #000000"><?php Array ( [0] => Array ( [parent] => Array ( [topic_id] => 2 [topic_title] => Dubai ) [child] => Array ( [topic_id] => 3 [topic_title] => Dubai Speicals ) ) [1] => Array ( [parent] => Array ( [topic_id] => 4 [topic_title] => Abu Dhabi ) [child] => Array ( [topic_id] => 5 [topic_title] => Abu Dubai Specials ) ) )
this is the pre recursive
how can i print this array properly in smarty template?