childroleobjarr as $childroleobj){ if('' == $resultstr){ $resultstr .= {$childroleobj->id}; }else{ $resultstr .= , {$childroleobj->id}; } exploderole($childroleobj, $resultstr); } }}//递归获取级联角色信息数组function makerolerelation(&$roleobjarr){ foreach($roleobjarr as $item){ $item->childroleobjarr = getroleobjarrbyparentid($item->id); if(0 childroleobjarr)){ makerolerelation($item->childroleobjarr); } }}//通过父角色的id获取子角色信息 function getroleobjarrbyparentid($parentid){ $opercogpstrtsysrole = new cogpstrtsysrole(); $opercogpstrtsysrole->setcolumn($opercogpstrtsysrole->getallcolumn()); $opercogpstrtsysrole->setwhere(parentroleid={$parentid}); $roleobjarr = $opercogpstrtsysrole->convresult2objarr($opercogpstrtsysrole->selecttable()); return isset($roleobjarr)?$roleobjarr:array();}
复制代码
>>> 您可能感兴趣的文章:php递归与迭代实现快速排序php递归获取目录内文件(包含子目录)的代码php无限级分类的递归函数php递归打印数组中所有元素的简单示例代码php递归遍历目录的二个函数php自定义函数递归替换数组中的内容php递归调用的小例子有关php数组递归遍历的一点理解php 数组递归求和的例子php实现的无极分类(递归)的代码php全排列的递归算法的代码