Re: Unexpected behavior of max() function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 11.12.2012 07:48, "Рогулин С.В." wrote:
I encountered with unexpected behavior of max() function. When i pass a
parameter ['100', '110,453351020813', '9'], this function gives answer '9'

var_dump(
    max(array('100', '110,453351020813', '9'))
);

// will output:
// string(1) "9"

As the output tells you, you are comparing strings and the character '9' is greater than the character '1' (at the beginning of the two other strings).

Bye, Andreas


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux