【问题标题】:Object Change into Array using Php [duplicate]使用 Php 将对象更改为数组 [重复]
【发布时间】:2017-07-16 08:19:25
【问题描述】:

我想改一下

    {"success":true,"data":{"transactionid":"83ad87ef-711a-4123-8273-92684daab934","messageid":"U3HuUCokq0PzvH0L7cIWiQ2"}}
{"success":true,"data":{"transactionid":"83ad87ef-711a-4123-8273-92684daab934","messageid":"U3HuUCokq0PzvH0L7cIWiQ2"}}

使用PHP进入数组...请指导..

【问题讨论】:

标签: php


【解决方案1】:

点击此链接:

http://php.net/manual/en/function.json-decode.php

希望对你有帮助。

【讨论】:

  • 谢谢..这很有帮助..:)
【解决方案2】:

使用json_decode() 函数将json 转换为array,第二个参数为true。像这样..

$json = '{"success":true,"data":{"transactionid":"83ad87ef-711a-4123-8273-92684daab934","messageid":"U3HuUCokq0PzvH0L7cIWiQ2"}}';
$array = json_decode($json,true);

print_r($array);

输出

Array
(
    [success] => 1
    [data] => Array
        (
            [transactionid] => 83ad87ef-711a-4123-8273-92684daab934
            [messageid] => U3HuUCokq0PzvH0L7cIWiQ2
        )

)

有关更多信息,请参阅文档json_decode()

【讨论】:

  • 这应该是怎么做的...谢谢...:)
猜你喜欢
  • 1970-01-01
  • 2021-12-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-03-18
  • 2016-02-09
  • 2017-09-02
相关资源
最近更新 更多