Strange problem max function cannot recognize parameters

Source: Internet
Author: User
Strange problem max function cannot recognize parameter PHP

$chrw = $this->GetArrStringWidth($chars, '', '', 0, true);array_walk($chrw, array($this, 'getRawCharWidth'));$maxchwidth = max($chrw);

The following error is reported: max () [function. max]: Array must contain at least one element
I output $ chrw content before the max function, which is array ([1] => 6.35 [2] => 6.35 [3] => 6.35)


Reply to discussion (solution)

If I write max (array (6.35, 6.35, 6.35), the error disappears.

Do you know what's going on ?? Why can't the max function recognize this parameter?

This is tcpdf code. I did not report an error locally, but I reported an error on the server.

$chrw = $this->GetArrStringWidth($chars, '', '', 0, true);array_walk($chrw, array($this, 'getRawCharWidth'));$maxchwidth = max($chrw);

The following error is reported: max () [function. max]: Array must contain at least one element
I output $ chrw content before the max function, which is array ([1] => 6.35 [2] => 6.35 [3] => 6.35)
In the max function, variables are allowed. If an error is returned, the array in the result is incorrect. array ([1] => 6.35 [2] => 6.35 [3] => 6.35)
I don't think this array is correct.

Array must contain at least one element
The array must contain at least one element.



In the max function, variables are allowed. If an error is returned, the array in the result is incorrect. array ([1] => 6.35 [2] => 6.35 [3] => 6.35)
I don't think this array is correct.

Sorry, I wrote it.
Array
(
[0] = & gt; 6.35
[1] => 6.35.
[2] => 6.35.
)

Array must contain at least one element
The array must contain at least one element.
The array is like this.
Array
(
[0] = & gt; 6.35
[1] => 6.35.
[2] => 6.35.
)
The array contains elements.

Var_dump ($ chrw) to see what it is

Var_dump ($ chrw) to see what it is

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

Php won't be wrong. He says it's empty, so it's empty!

$ Chrw = $ this-> GetArrStringWidth ($ chars, '','', 0, true );
Var_dump ($ chrw );
Array_walk ($ chrw, array ($ this, 'getrawcharwidth '));
Var_dump ($ chrw );
$ Maxchwidth = max ($ chrw );

Take a look

Php won't be wrong. He says it's empty, so it's empty!

$ Chrw = $ this-> GetArrStringWidth ($ chars, '','', 0, true );
Var_dump ($ chrw );
Array_walk ($ chrw, array ($ this, 'getrawcharwidth '));
Var_dump ($ chrw );
$ Maxchwidth = max ($ chrw );

Take a look

I did what you said and read them separately, but all the output is
Array (3) {[0] => float (6.35) [1] => float (6.35) [2] => float (6.35 )}

Php won't be wrong. He says it's empty, so it's empty!

$ Chrw = $ this-> GetArrStringWidth ($ chars, '','', 0, true );
Var_dump ($ chrw );
Array_walk ($ chrw, array ($ this, 'getrawcharwidth '));
Var_dump ($ chrw );
$ Maxchwidth = max ($ chrw );

Take a look

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 )}

Even though max reports an error, my echo $ maxchwidth is 6.35.

Spiritual events
And the local server is correct.

Are all var_dump tests performed locally? Test it on the faulty server.

Even though max reports an error, my echo $ maxchwidth is 6.35.

Then you need to check whether there are other places where max () is used. if not, an error is reported elsewhere.

Spiritual events
And the local server is correct.

Are all var_dump tests performed locally? Test it on the faulty server.
Well, it's tested on the server.


Even though max reports an error, my echo $ maxchwidth is 6.35.

Then you need to check whether there are other places where max () is used. if not, an error is reported elsewhere.

Max () [function. max]: Array must contain at least one elementError File: \ supported des \ plugin \ tcpdf. php at 6301 line.
> Report_issue
> Back to previous page


Even though max reports an error, my echo $ maxchwidth is 6.35.

Then you need to check whether there are other places where max () is used. if not, an error is reported elsewhere.
If the number of rows is specified

Before maxcompute, use array_values ($ chrw) to process the array.

Thank you. I don't know what's going on. I can do it myself today.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.