使用PHP在输出中拆分数据集

时间:2015-02-16 06:11:45

标签: php

如何使用php吐出这组数据?这个数据从一些php生成到我的mysql数据库。

[{"id":"1","is_email":"false","add_to_day_hour_info":"false","add_to_day_hour_body":"false","translation":"Company","value":"Destination Queenstown"},{"id":"2","is_email":"false","add_to_day_hour_info":"false","add_to_day_hour_body":"false","translation":"Your Name","value":"Ella Zhang"}]

现在我只需要在输出中获得id=2及其值。

1 个答案:

答案 0 :(得分:0)

这是JSON数据。请尝试使用 -

$array = '[{"id":"1","is_email":"false","add_to_day_hour_info":"false","add_to_day_hour_body":"false","translation":"Company","value":"Destination Queenstown"},{"id":"2","is_email":"false","add_to_day_hour_info":"false","add_to_day_hour_body":"false","translation":"Your Name","value":"Ella Zhang"}]';

$array = json_decode($array);

echo $array[1]->id;