Example #1
0
function recursive_print($id, $comm, $hier, &$ret)
{
    if (isset($comm[$id])) {
        $ret[] = array('id' => $id, 'timestamp' => $comm[$id]['ts'], 'author' => $comm[$id]['author'], 'reply_to' => $comm[$id]['parent'], 'text' => htmlspecialchars($comm[$id]['text']));
    }
    if (!isset($hier[$id])) {
        return;
    }
    if (!$id) {
        foreach ($hier[$id] as $cid) {
            recursive_print($cid, $comm, $hier, $ret);
        }
    } else {
        foreach (array_reverse($hier[$id]) as $cid) {
            recursive_print($cid, $comm, $hier, $ret);
        }
    }
}
Example #2
0
 function recursive_print($array, $parentkey = '', $level = 0)
 {
     foreach ($array as $key => $value) {
         if (is_array($value)) {
             // check if there is a numeric key in the sub-array, if so, we don't print the title
             if (!isset($value[0])) {
                 $this->writeln(str_pad($key, 15 + $level * 3, ' ', STR_PAD_LEFT) . ': ');
             }
             recursive_print($value, $key, $level + 1);
         } else {
             if (is_numeric($key)) {
                 // its just multiple parent keys, so we don't indent, and print the parentkey instead
                 $this->writeln(str_pad($parentkey, 15 + ($level - 1) * 3, ' ', STR_PAD_LEFT) . ': ' . $value);
             } else {
                 if ($key == 'status') {
                     switch ($value) {
                         case MODULE_STATUS_NOTINSTALLED:
                             $value = 'Not Installed';
                             break;
                         case MODULE_STATUS_NEEDUPGRADE:
                             $value = 'Disabled; Needs Upgrade';
                             break;
                         case MODULE_STATUS_ENABLED:
                             $value = 'Enabled';
                             break;
                         case MODULE_STATUS_DISABLED:
                             $value = 'Disabled';
                             break;
                         case MODULE_STATUS_BROKEN:
                             $value = 'Broken';
                             break;
                     }
                 }
                 $this->writeln(str_pad($key, 15 + $level * 3, ' ', STR_PAD_LEFT) . ': ' . $value);
             }
         }
     }
 }
 public static function recursive_print($varname, $varval)
 {
     if (is_array($varval) == false) {
         print $varname . ' = ' . var_export($varval, true) . ";<br>\n";
     } else {
         print $varname . " = array();<br>\n";
         foreach ($varval as $key => $val) {
             recursive_print($varname . "[" . var_export($key, true) . "]", $val);
         }
     }
 }