下記の様にRSSから情報を取得しているのですが、$contentsの中の日本語が上手くjsonencodeされず、添付ファイルのように表示されてしまいます。
$x["title"]等に直接同じ文字列を入れるとちゃんと表示されます。
もしわかる方いましたらご教授頂けると幸いです。
何卒よろしくお願い致します。
require_once './phpQuery-onefile.php';
//RSS取得
$rss = simplexml_load_file('https://www.google.co.jp/alerts/feeds/03691758709039141869/17529887448766499343', 'SimpleXMLElement', LIBXML_NOCDATA);
$contents = array();
for ($num = 0; $num < count($rss->entry); $num++) {
$x["link"] = mb_convert_encoding($rss->entry[$num]->link->attributes()->href,"HTML-ENTITIES","utf8");
$x["title"] = (String)mb_convert_encoding($rss->entry[$num]->title,"HTML-ENTITIES","utf8");
$x["content"] = htmlspecialchars (mb_convert_encoding($rss->entry[$num]->content,"HTML-ENTITIES","utf8"));
array_push($contents,$x);
}
echo json_encode($contents);
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。