/** * Render a dump for an array * * @param mixed $data * @param string $name * @access private * @static */ private static function _array($data, $name) { $config_sort = Dumper::_config('display', 'sort_arrays', true); // If the sort is enabled in the config (default = yes) and the array is assoc (non-numeric) if (sizeof($data) > 1 && $config_sort && Dumper::is_assoc($data)) { // Copy the array to a temp variable and sort it $new = $data; ksort($new); // If the sorted array is the same as the old don't sort it if ($new === $data) { $sort = 0; } else { $data = $new; $sort = 1; } } else { $sort = 0; } $childCount = count($data); $collapsed = Dumper::_isCollapsed(self::$_level, count($data)); // Setup the CSS classes depending on how many children there are if ($childCount > 0 && $collapsed) { $elementClasses = ' dumper-expand'; } elseif ($childCount > 0) { $elementClasses = ' dumper-expand dumper-opened'; } else { $elementClasses = ''; } print "<li class=\"dumper-child\">"; print "<div class=\"dumper-element {$elementClasses}\""; // If there is more than one, make a dropdown if (count($data) > 0) { print "onClick=\"dumper.toggle(this);\""; } print "onMouseOver=\"dumper.over(this);\" onMouseOut=\"dumper.out(this);\">"; print "<a class=\"dumper-name\">{$name}</a> <em class=\"dumper-type\">arr(<strong class=\"dumper-array-length\">"; print count($data) . "</strong>)</em>"; if (count($data) > 0) { print " …"; } if ($sort) { $title = "Array has been sorted prior to display. This is configurable in dumper.ini."; print " - <span title=\"{$title}\"><strong class=\"dumper-sorted\">Sorted</strong></span>"; } // callback if (is_callable($data)) { $_ = array_values($data); print "<span class=\"dumper-callback\"> |"; print " (<em class=\"dumper-type\">Callback</em>) <strong class=\"dumper-string\">"; if (!is_object($_[0])) { echo htmlSpecialChars($_[0]); } else { echo htmlSpecialChars(get_class($_[0])) . "::"; } echo htmlSpecialChars($_[1]) . "()</strong></span>"; } print "</div>"; if (count($data)) { Dumper::_vars($data); } print "</li>"; }