php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #38883 Issue with min function when a numeric sting is passed in.
Submitted: 2006-09-19 15:31 UTC Modified: 2007-08-17 16:34 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: ryanhollett at hotmail dot com Assigned:
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS: Windows XP sp2
Private report: No CVE-ID: None
 [2006-09-19 15:31 UTC] ryanhollett at hotmail dot com
Description:
------------
From the php documentation for the min function "PHP will evaluate a non-numeric string as 0, but still return the string if it's seen as the numerically lowest value."

It seems that this is incorrect.  When a non-numeric string and a numeric string are passed in, the numeric string seems to be returned as the the min value.

Reproduce code:
---------------
<?php

echo min("a", "2");
echo "\n";
echo min("2", "a");
echo "\n";
echo min("a", "-2");
echo "\n";
echo min("-2", "a");

?>

Expected result:
----------------
a
a
-2
-2

Actual result:
--------------
2
2
-2
-2

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-09-19 15:34 UTC] ryanhollett at hotmail dot com
This was tested on version 4.4.0, 4.4.1, 4.4.4 for Windows.  This may be a documentation problem or an issue with the function itself depending on the intended functionality.
 [2007-08-17 16:34 UTC] vrana@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.

"PHP will evaluate a non-numeric string as 0 if compared to integer, ..."
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Nov 19 19:00:01 2025 UTC