【问题标题】:Generate file JSON from PHP script [closed]从 PHP 脚本生成文件 JSON [关闭]
【发布时间】:2018-09-01 00:48:10
【问题描述】:

如何从 PHP 脚本生成这个结构文件 JSON?

示例 JSON:

{
   "messages":[
      {
         "attachment":{
            "type":"image",
            "payload":{
               "url":"#"
            }
         }
      }
   ]
}

谢谢:)

【问题讨论】:

  • 至少做一些努力并阅读php如何与json一起工作。
  • a google of: "json php" and top result is an example of json_encode()

标签: php arrays json php-7


【解决方案1】:

应该可以的。

$a = ["messages" => [["attachment" => ["type" => "image", "payload" => ["url" => "#"]]]]];
$b = json_encode ($a);

【讨论】:

    猜你喜欢
    • 2016-04-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-06-08
    • 1970-01-01
    • 1970-01-01
    • 2014-04-17
    • 1970-01-01
    相关资源
    最近更新 更多