php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #717 The type of array keys is being lost
Submitted: 1998-09-02 12:53 UTC Modified: 1998-09-20 19:23 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:0 of 1 (0.0%)
From: obyrne at iol dot ie Assigned: zeev (profile)
Status: Closed Package: Misbehaving function
PHP Version: 3.0.3 OS: Digital Unix
Private report: No CVE-ID: None
 [1998-09-02 12:53 UTC] obyrne at iol dot ie
<HTML><HEAD><TITLE>Test PHP3 Script</TITLE>
</HEAD><BODY>
<?php

$longstring="123456789012345";
$vals["$longstring"]=1;
echo "<p>Setting array ",gettype($longstring)," element $longstring with ",
  $vals["$longstring"],"</p>\n";
while (list($arg,$val)=each($vals)) {
  echo "<p>Got array ",gettype($arg)," element $arg = $val </p>\n";
}
?>
</BODY></HTML>

gives :-

Setting array string element 123456789012345 with 1

Got array integer element -2045911175 = 1 


My configuration is Apache-1.3.1 with mod_ssl, php2 and php3.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1998-09-20 19:23 UTC] zeev
Fixed, there were a few things that were 32-bit specific
in the code.

As for why the string is being converted to a number,
this is how PHP works.  If a string index appears to
be numeric, it is automatically converted to be numeric,
in order to prevent $foo["7"] from being different
from $foo[7] (which is something you really don't want,
trust me)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 03 18:01:34 2024 UTC