is_assoc() private static method

private static is_assoc ( $var )
Example #1
0
 /**
  * Render a dump for an array
  *
  * @param mixed $data
  * @param string $name
  * @access private
  * @static
  */
 private static function _array($data, $name)
 {
     $config_sort = Krumo::_config('sorting', '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 && Krumo::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 = Krumo::_isCollapsed(self::$_level, count($data));
     // Setup the CSS classes depending on how many children there are
     if ($childCount > 0 && $collapsed) {
         $elementClasses = ' krumo-expand';
     } elseif ($childCount > 0) {
         $elementClasses = ' krumo-expand krumo-opened';
     } else {
         $elementClasses = '';
     }
     if (count($data) > 1 || count($data) == 0) {
         $plural = 's';
     } else {
         $plural = '';
     }
     print "<li class=\"krumo-child\">";
     print "<div class=\"krumo-element {$elementClasses}\"";
     // If there is more than one, make a dropdown
     if (count($data) > 0) {
         print "onClick=\"krumo.toggle(this);\"";
     }
     print "onMouseOver=\"krumo.over(this);\" onMouseOut=\"krumo.out(this);\">";
     print "<a class=\"krumo-name\">{$name}</a> <em class=\"krumo-type\">Array(<strong class=\"krumo-array-length\">";
     print count($data) . "</strong>)</em>";
     if (count($data) > 0) {
         print " &hellip;";
     }
     if ($sort) {
         $title = "Array has been sorted prior to display. This is configurable in krumo.ini.";
         print " - <span title=\"{$title}\"><strong class=\"krumo-sorted\">Sorted</strong></span>";
     }
     // callback
     if (is_callable($data)) {
         $_ = array_values($data);
         print "<span class=\"krumo-callback\"> |";
         print " (<em class=\"krumo-type\">Callback</em>) <strong class=\"krumo-string\">";
         if (!is_object($_[0])) {
             echo htmlSpecialChars($_[0]);
         } else {
             echo htmlSpecialChars(get_class($_[0])) . "::";
         }
         echo htmlSpecialChars($_[1]) . "()</strong></span>";
     }
     print "</div>";
     if (count($data)) {
         Krumo::_vars($data);
     }
     print "</li>";
 }