我有一个这样的字符串
{"Account":{"Currency":"SGD","CreditLimit":0.0000,"Balance":1649.5700},"Status":36,"Code":891,"Message":"Success"}-
我需要平衡的值。
我试过这样。
$string = '{"Account":{"Currency":"SGD","CreditLimit":0.0000,"Balance":1649.5700},"Status":1,"Code":1,"Message":"Success"}-';
$withCharacter = strstr($string, 'Balance":');
echo substr($withCharacter, 1);
也试过使用explode,但没有成功。
这似乎是一个有效的JSON,为什么不呢?json_decode
并找出数值。
$i = json_decode('{"Account":{"Currency":"SGD","CreditLimit":0.0000,"Balance":1649.5700},"Status":36,"Code":891,"Message":"Success"}');
echo $i->Account->Balance;