【问题标题】:how to save text files as array format? [closed]如何将文本文件保存为数组格式? [关闭]
【发布时间】:2018-05-09 10:39:24
【问题描述】:

我想使用 PHP 将文本文件保存为以下格式,

我有一个这样的 PHP 数组

Array
(
    [0] => Array
        (
            [email] => sample@gmail.com
            [status]=> success

        )

    [1] => Array
        (
            [email] => samplewallace@gmail.com
            [status]=> success
        )
)

我需要将上面的数组保存在文本文件中,格式如下

[
     {
        "email": "sample@gmail.com",
        "status": "success",

      },
      {
        "email": "sample@gmail.com",
        "status": "success",
      },
    ]

【问题讨论】:

标签: php


【解决方案1】:

给你,

file_put_contents( 'filename.txt', json_encode( $array ) );

【讨论】:

猜你喜欢
  • 2014-11-25
  • 1970-01-01
  • 2020-03-02
  • 1970-01-01
  • 2013-08-07
  • 2012-06-07
  • 2016-12-20
  • 2015-01-23
  • 2013-04-13
相关资源
最近更新 更多