我使用json创建了一个文件并将其导出。它使用它创建HTML标记。实际上,我不想让html部分出现在文件中。下面我分享了我当前文件的结构:HTML默认标记,如head、title等,下面是json alon。
<html xmlns="http://www.w3.org/1999/xhtml" class="wp-toolbar" lang="en-US">
<!--<![en-->
[{
"ID" : 13,
"post_author" : "1",
"post_date" : "2015-10-30 07:09:16",
"post_date_gmt" : "2015-10-30 07:09:16",
"post_content" : "Test",
"post_title" : "Test",
"post_excerpt" : "",
"post_status" : "publish",
"comment_status" : "closed",
"ping_status" : "closed",
"post_password" : "",
"post_name" : "test",
"to_ping" : "",
"pinged" : "",
"post_modified" : "2015-10-30 07:09:16",
"post_modified_gmt" : "2015-10-30 07:09:16",
"post_content_filtered" : "",
"post_parent" : 0,
"guid" : "url/?post_type=wpcp_pointer&p=9",
"menu_order" : 0,
"post_type" : "wpcp_pointer",
"post_mime_type" : "",
"comment_count" : "0",
"filter" : "raw"
}
]
但我想要的是:
[{
"ID" : 13,
"post_author" : "1",
"post_date" : "2015-10-30 07:09:16",
"post_date_gmt" : "2015-10-30 07:09:16",
"post_content" : "Test",
"post_title" : "Test",
"post_excerpt" : "",
"post_status" : "publish",
"comment_status" : "closed",
"ping_status" : "closed",
"post_password" : "",
"post_name" : "test",
"to_ping" : "",
"pinged" : "",
"post_modified" : "2015-10-30 07:09:16",
"post_modified_gmt" : "2015-10-30 07:09:16",
"post_content_filtered" : "",
"post_parent" : 0,
"guid" : "url/?post_type=wpcp_pointer&p=9",
"menu_order" : 0,
"post_type" : "wpcp_pointer",
"post_mime_type" : "",
"comment_count" : "0",
"filter" : "raw"
}
]
只有JSON数组存在文件导出。请帮助我如何从json文件中删除html部分。以下是用于生成此代码的编码部分:
$json_file = json_encode($need_options); // Encode data into json data
$json_file = stripslashes($json_file);
echo $json_file;
header("Content-Type: text/json; charset=" . get_option( \'blog_charset\'));
header("Content-Disposition: attachment; filename=$json_name.json");
exit();
任何帮助都会得到很好的回报。