json_encode json_decode 整型溢出的问题
程序员文章站
2022-05-13 12:38:23
...
php版本5.2-5.3 不能升级到5.4的情况下 有下面一段代码
输出的是:Array( [lastRev] => 20150517175733 [fileList] => Array ( [count] => 4 [folder] => Array ( [0] => Array ( [id] => 9.1550136349934E+14 [name] => demo [createDate] => 2015-05-17 17:49:03 [lastOpTime] => 2015-05-17 17:49:03 [rev] => 20150517174903 ) ) [file] => Array ( [0] => Array ( [id] => 9.130313632168E+14 [name] => yueyuhuashi..mp4 [size] => 28444469 [md5] => 179954914C459FE29885A077A1A62B5E [lastOpTime] => 2015-05-17 10:45:31 [createDate] => 2015-05-17 10:45:31 [mediaType] => 3 [rev] => 20150517104531 ) [1] => Array ( [id] => 6.1303136356971E+14 [name] => 多元神话 - 火火中国风(广场舞版).mp3 [size] => 15436145 [md5] => 1700981A8F72B46F2ED50914D7F0F997 [lastOpTime] => 2015-05-17 10:42:44 [createDate] => 2015-05-17 10:42:44 [mediaType] => 2 [rev] => 20150517104244 ) [2] => Array ( [id] => 1.1399136319503E+14 [name] => 7.jpg [size] => 1851 [md5] => 0A7211CE8E736AD4E2CE36E18CC08E65 [lastOpTime] => 2015-05-17 10:17:41 [createDate] => 2015-05-17 10:10:36 [mediaType] => 1 [rev] => 20150517101741 ) ) ))
可以发现 [id] => 已经溢出了 求解决办法
回复讨论(解决方案)
你不给长数字加上引号,哪能怪谁呢?
版主 那个json 是不可控的 人家API提供的就是这样的数据,,,,,
$json = preg_replace('/("id":)(\d{9,})/i', '${1}"${2}"', $json); 结贴搞定
上一篇: Oracle sql 语句分析