如何从JSON数组中分离元素

时间:2014-07-08 17:47:25

标签: php json

我正在执行 php 脚本并获得以下结果:

[{"0":"1010100000100000100","nonnull_columns":"1010100000100000100"}]

我可以提取第二个引用中引用的字符串,即1010100000100000100 ??

1 个答案:

答案 0 :(得分:0)

它是数组中的一个对象。

$json_string = '[{"0":"1010100000100000100","nonnull_columns":"1010100000100000100"}]';
$json_decoded = json_decode($json_string);
$first_element = $json_decoded[0];
$nonnull_columns = $first_element->nonnull_columns;

以上代码当然可以缩短。

相关问题