Edit report at http://bugs.php.net/bug.php?id=53301&edit=1
ID: 53301 Updated by: [email protected] Reported by: rbysa at yahoo dot com Summary: http_build_query unexpected behavior -Status: Bogus +Status: Open Type: Bug Package: *General Issues Operating System: Ubuntu PHP Version: 5.3.3 Block user comment: N New Comment: I got the expected result... Array ( [1234567890123] => foo ) Previous Comments: ------------------------------------------------------------------------ [2010-11-12 22:38:08] rbysa at yahoo dot com Your example does not represent the problem. In my haste I messed up my own example code but here it is again. $var = "1234567890123"; $varArray = array(); $varArray[$var]= "foo"; $build = http_build_query($varArray); $result = array(); parse_str($build, $result); print_r($result); //Expect Array( "1234567890123"=>"foo") //Actual Array( "123456789012" =>"foo") ------------------------------------------------------------------------ [2010-11-12 22:00:14] [email protected] You need to use: $var = array('12345678901' => 'foo'); var_dump(http_build_query($var)); As said in the other bug report. ------------------------------------------------------------------------ [2010-11-12 20:34:25] rbysa at yahoo dot com Also I do want to mention that I saw the previous bug report on this issue http://bugs.php.net/bug.php?id=49023 However this bug report has been labeled "bogus" even though the documentation does not support the mentioned behavior. ------------------------------------------------------------------------ [2010-11-12 20:26:35] rbysa at yahoo dot com Description: ------------ http_build_query truncates large integer keys to 12 digits regardless of them being passed as a string, integer, or float. However if the integer value is cast to a string and appended with non-integer characters the key is not truncated. Test script: --------------- $var = 1234567890123 echo http_build_query($var); $var = (string)1234567890123 echo http_build_query($var); $var = (float)1234567890123 echo http_build_query($var); $var = "1234567890123.asd" echo http_build_query($var); Expected result: ---------------- Array([0]=>1234567890123) Array([0]=>1234567890123) Array([0]=>1234567890123) Array([0]=>"1234567890123.asd") Actual result: -------------- Array([0]=>123456789012) Array([0]=>123456789012) Array([0]=>123456789012) Array([0]=>"1234567890123.asd") ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=53301&edit=1
