【问题标题】:Decode and get data of JS object in PHP用PHP解码并获取JS对象的数据
【发布时间】:2011-10-07 05:15:14
【问题描述】:

我有一个名为

的变量
var type = [];

我在哪里

type.push({'type' : 1});

最后我得到以下对象:

[{"type":"1"},{"type":"2"},{"type":"3"},{"type":"4"}]

通过 JSON.stringify();

但是我怎样才能在 PHP 中获取类型呢?

【问题讨论】:

    标签: php javascript json object stringify


    【解决方案1】:

    您可以使用json_decode

    $object = json_decode($json);
    

    【讨论】:

    • 工作代码:$types = json_decode($this->types);回声$类型[0]->类型;谢谢
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-07-08
    • 1970-01-01
    • 2021-02-04
    • 1970-01-01
    • 1970-01-01
    • 2020-06-04
    • 2023-04-04
    相关资源
    最近更新 更多