/** * 获取数组大小 * * @param mixed $arr 数组 * @return string */ public static function array_size($arr) { ob_start(); print_r($arr); $mem = ob_get_contents(); ob_end_clean(); $mem = preg_replace("/\n +/", "", $mem); $mem = strlen($mem); return self::format_bytes($mem); }// 转换大小单位 public static function format_bytes($size) { $unit = array('b', 'kb', 'mb', 'gb', 'tb', 'pb'); return @round($size / pow(1024, ($i = floor(log($size, 1024)))), 2) . ' ' . $unit[$i]; }
转载于:https://my.oschina.net/yonghan/blog/898407