【问题标题】:How to separate elements from JSON array如何从 JSON 数组中分离元素
【发布时间】:2014-08-29 13:51:18
【问题描述】:

我正在执行一个 php 脚本并得到以下结果:

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

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

【问题讨论】:

标签: php json


【解决方案1】:

它是一个数组中的对象。

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

上面的代码当然可以缩短。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-09-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多