JSON APIを使用しており、html タグなしで投稿コンテンツ (クリア テキスト) を解析したいと考えています。
使用してみhtmlspecialchars(json_encode($posts))
ましstrip_tags($posts);
たが、JSON から html タグを削除できませんでした。
私はphpが初めてなので、適切に配置しているかどうかわかりません。
public function get_category_posts() {
global $json_api;
$category = $json_api->introspector->get_current_category();
if (!$category) {
$json_api->error("Not found.");
}
$posts = $json_api->introspector->get_posts(array(
'cat' => $category->id
));
$result = strip_tags($posts);
return $this->posts_object_result($result, $category);
}
JSON :
"posts": [
{
"id": 3454,
"type": "post",
"status": "publish",
"title": "XYZ JOINS",
"content": "<p>This is the content that should not have html tags.<\/p>\n",
"date": "2012-05-16 22:06:55"
}
]
<p></p>
上記のjsonからhtmlタグを削除したい。コンテンツには多くの div およびその他の html タグがあります。