$chrw = $this->GetArrStringWidth($chars, '', '', 0, true);
array_walk($chrw, array($this, 'getRawCharWidth'));
$maxchwidth = max($chrw);报这样的错误  max() [function.max]: Array must contain at least one element
我在max函数之前输出$chrw 有内容,是array([1]=>6.35 [2]=>6.35 [3]=>6.35)
PHP

解决方案 »

  1.   

    如果我写max(array(6.35,6.35,6.35)),则错误消失
      

  2.   

    大神们知道怎么回事么??为啥max函数识别不出这个参数
      

  3.   

    这是 tcpdf类的代码,我本地没有报错,但是在服务器上就报错
      

  4.   

    max函数里肯定是可以放变量的,报错说明里面的数组有问题,array([1]=>6.35 [2]=>6.35 [3]=>6.35)
    这个数组我怎么看都感觉不对啊
      

  5.   

    Array must contain at least one element
    阵列必须包含至少一种元素
      

  6.   



    max函数里肯定是可以放变量的,报错说明里面的数组有问题,array([1]=>6.35 [2]=>6.35 [3]=>6.35)
    这个数组我怎么看都感觉不对啊不好意思,那是我手写的,是这样的
    Array
    (
        [0] => 6.35
        [1] => 6.35
        [2] => 6.35
    )
      

  7.   

    数组是这样的
    Array
    (
        [0] => 6.35
        [1] => 6.35
        [2] => 6.35
    )
    数组里面有元素啊
      

  8.   


    array(3) { [0]=> float(6.35) [1]=> float(6.35) [2]=> float(6.35) } 
      

  9.   

    php 是不会弄错的,他说是空的那么就是空的了!$chrw = $this->GetArrStringWidth($chars, '', '', 0, true);
    var_dump($chrw);
    array_walk($chrw, array($this, 'getRawCharWidth'));
    var_dump($chrw);
    $maxchwidth = max($chrw);分别看一下
      

  10.   


    我按照您说的做了,分别看了下,但是输出的都是
    array(3) { [0]=> float(6.35) [1]=> float(6.35) [2]=> float(6.35) }
      

  11.   


    array(3) { [0]=> float(6.35) [1]=> float(6.35) [2]=> float(6.35) } array(3) { [0]=> float(6.35) [1]=> float(6.35) [2]=> float(6.35) }
      

  12.   

    还有奇怪的,max虽然报错了,但是我 echo $maxchwidth  竟然是6.35
      

  13.   

    灵异事件
    而且本地没错,服务器错你上面的var_dump是否都在本地测试啊?要在出错的服务器上测试啊
      

  14.   


    那你就要检查是否还有别的地方用了max(),说不准是其他地方报错
      

  15.   


    那你就要检查是否还有别的地方用了max(),说不准是其他地方报错max() [function.max]: Array must contain at least one elementError File: \includes\plugin\tcpdf\tcpdf.php at 6301 line.
    >> report_issue
    >> 返回上一页
      

  16.   


    那你就要检查是否还有别的地方用了max(),说不准是其他地方报错
    指定行数了就说在这一行
      

  17.   

    max计算前用 array_values($chrw) 处理下数组试试