php recursive example php recursive function code

WBOY
Release: 2016-07-25 08:54:34
Original
1032 people have browsed it
  1. //Recursively get the role ID string
  2. function explodeRole($roleObj, &$resultStr){
  3. if(0 < count($roleObj->childRoleObjArr)){
  4. foreach( $roleObj->childRoleObjArr as $childRoleObj){
  5. if('' == $resultStr){
  6. $resultStr .= "{$childRoleObj->id}";
  7. }else{
  8. $resultStr .= ", { $childRoleObj->id}";
  9. }
  10. explodeRole($childRoleObj, $resultStr);
  11. }
  12. }
  13. }
  14. //Recursively obtain the cascaded role information array
  15. function makeRoleRelation(&$roleObjArr){
  16. foreach($ roleObjArr as $item){
  17. $item->childRoleObjArr = getRoleObjArrByParentId($item->id);
  18. if(0 < count($item->childRoleObjArr)){
  19. makeRoleRelation($item->childRoleObjArr ; getAllColumn());
  20. $operCOGPSTRTSysRole->setWhere("parentroleid={$parentid}");
  21. $roleObjArr = $operCOGPSTRTSysRole->convResult2ObjArr($operCOGPSTRTSysRole->selectTable());
  22. return isset($roleObjArr )?$roleObjArr:array();
  23. }
  24. Copy code
  25. >>> Articles you may be interested in:
  26. PHP recursion and iteration to implement quick sort
php code to recursively obtain files in a directory (including subdirectories) php infinite classification recursive function

Simple example code for PHP to recursively print all elements in an array Two functions for php to recursively traverse directories php custom function recursively replaces the contents of an array Small example of php recursive call A little understanding of recursive traversal of PHP arrays php array recursive summation example Code of infinite classification (recursive) implemented by php php fully permuted recursive algorithm code

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!