当前位置: 首页>>代码示例>>PHP>>正文


PHP Dumper::is_assoc方法代码示例

本文整理汇总了PHP中Dumper::is_assoc方法的典型用法代码示例。如果您正苦于以下问题:PHP Dumper::is_assoc方法的具体用法?PHP Dumper::is_assoc怎么用?PHP Dumper::is_assoc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Dumper的用法示例。


在下文中一共展示了Dumper::is_assoc方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _array

 /**
  * 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 " &hellip;";
     }
     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>";
 }
开发者ID:aleksabp,项目名称:bolt,代码行数:70,代码来源:class.dumper.php


注:本文中的Dumper::is_assoc方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。