php 長整型轉字串 (convert long to string)
阿新 • • 發佈:2019-02-16
問題描述:
原始資料 (before deal)
{"id":5730528714937479169,"fullname":"rourou","email":null,"mobile":"1391730****","description":null}
json_decode後 (after json_decode)
array(5) { ["id"]=> float(5.7305287149375E+18) ["fullname"]=> string(6) "rourou" ["email"]=> NULL ["mobile"]=> string(11) "1391730****" ["description"]=> NULL }
處理方法(deal method)
$response={"id":5730528714937479169,"fullname":"rourou","email":null,"mobile":"1391730****","description":null}
preg_replace('/^\{"id":(\d{1,})./', '{"id":"\\1",', $response);
處理後(after deal)
$response={"id":"5730528714937479169","fullname":"rourou","email":null,"mobile":"1391730****","description":null}