Posted By

jatkins on 01/16/17


Tagged

recursive recursion


Versions (?)

To help me understand recursion...


 / Published in: PHP
 

Released into the public domain 2017 by Josh Atkins.

  1. global $fullPaths;
  2. $GLOBALS['fullPaths'] = array();
  3. function renderSource($nodes) {
  4. $files = array();
  5. if (is_array($nodes)) {
  6. foreach($nodes as $nodeKey => $node) {
  7. $files[basename($nodeKey)] = renderSource($node);
  8. }
  9. } else {
  10. $GLOBALS['fullPaths'][] = $nodes;
  11. $files = $nodes;
  12. }
  13. return $files;
  14. }

Report this snippet  

You need to login to post a comment.