php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #52347 Unsigned integer becomes signed and negative, when using as an array key
Submitted: 2010-07-15 13:59 UTC Modified: 2010-11-30 14:25 UTC
Votes:1
Avg. Score:2.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: 2tl at mail dot ru Assigned:
Status: Not a bug Package: Arrays related
PHP Version: 5.3.2 OS: Linux 2.6.33.5-124.fc13.i686.PAE
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: 2tl at mail dot ru
New email:
PHP Version: OS:

 

 [2010-07-15 13:59 UTC] 2tl at mail dot ru
Description:
------------
There is a simple html form
<input type="text" name="inventory[2391649236][product_code]" />

when post it, the $_REQUEST will be as below:
Array
(
    [inventory] => Array
        (
            [-1903318060] => Array
                (
                    [product_code] => 
                )
        )
)

Why 2391649236 become -1903318060?

In my case, "2391649236" is just unique index. I got it with sprintf("%u", 
crc32($my_data));

Test script:
---------------
<form>
<input type="text" name="inventory[2391649236][product_code]" />
<input type="submit" />
</form>
<?php print_r($_REQUEST) ?>

Expected result:
----------------
Array
(
    [inventory] => Array
        (
            [2391649236] => Array
                (
                    [product_code] => 
                )
        )
)

Actual result:
--------------
Array
(
    [inventory] => Array
        (
            [-1903318060] => Array
                (
                    [product_code] => 
                )
        )
)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-07-15 14:05 UTC] 2tl at mail dot ru
-Summary: Long int becomes negative, when using as array key +Summary: Unsigned integer becomes signed and negative, when using as an array key
 [2010-07-15 14:05 UTC] 2tl at mail dot ru
Changed title to unsigned int
 [2010-11-30 14:25 UTC] iliaa@php.net
-Status: Open +Status: Bogus
 [2010-11-30 14:25 UTC] iliaa@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 01:01:28 2024 UTC