array原样写入txt

$file = "log.txt";
$content=array(
    "name"=>"百度知道",
    "company"=>"百度在线",
    "city"=>"北京",
    "other"=>array(
        "edu"=>"百度教育",
        "jingyan"=>"百度经验",
    )
);
file_put_contents($file,var_export($content,true)."\r\n",FILE_APPEND);

//写入结果[Notepad打开正常]
/**
array (
    'name' => '百度知道',
    'company' => '百度在线',
    'city' => '北京',
    'other' =>
    array (
        'edu' => '百度教育',
        'jingyan' => '百度经验',
    ),
)
 */

猜你喜欢

转载自blog.csdn.net/oHeiZhiShi123/article/details/82746792