function printarray($array) { if (is_object($array)) { return printObject($array); } if (!is_array($array)) { return; } while (list($key, $value) = each($array)) { if (is_array($value)) { echo $key . '(array):<blockquote>'; printarray($value); //recursief!! echo '</blockquote>'; } elseif (is_object($value)) { echo $key . '(object):<blockquote>'; printobject($value); echo '</blockquote>'; } else { echo $key . '==>' . $value . '<br />'; } } }
function printarray($array) { if (is_object($array)) { return printObject($array); } if (!is_array($array)) { return; } while (list($key, $value) = each($array)) { if (is_array($value)) { echo $key . "(array):<blockquote>"; printarray($value); //recursief!! echo "</blockquote>"; } elseif (is_object($value)) { echo $key . "(object):<blockquote>"; printobject($value); echo "</blockquote>"; } else { echo $key . "==>" . $value . "<br />"; } } }
function printval($object, $index, $link = 0, $nulldisp = ' ') { $data = ''; if (isset($object[$index])) { if (is_array($object[$index])) { $data .= printarray($object, $index, $link = 0, $nulldisp = ' '); } else { $data .= getlookup($object[$index]); if ($link) { $data = "<a href='#{$object[$index]}'>{$data}</a>"; } } } else { $data .= $nulldisp; } return $data; }
function dumparray($a) { // provide a debugging output similar to var_dump, without breaking execution if (!is_array($a)) { return false; } $output = " Array("; foreach ($a as $key => $value) { if (is_array($value)) { $output .= "<br>[{$key}] => <br>" . printarray($value); } else { $output .= "'{$key}' => '{$value}'<br>"; } } $output .= ") <br>"; return $output; }
<?php function printarray(array $x) { echo "<pre>"; print_r($x); echo "</pre>"; } $a = array(1, 2, 3, 4, 5, 6, 7); printarray($a);