php 长整型转字符串 (convert long to string)

问题描述:

原始数据 (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}