我使用php json_decode解析API响应,然后json_encode发送响应到客户端。php json_decode删除html标签
在第三方API调用中,我得到JSON响应,其中有一个具有html标记和html内容的值的键。当我打印这些数据时,我可以看到这些标签,但在json_decode之后,我看不到这些标签,因此我无法保持这些标签的完整性。我希望这些html内容能够直接进入数据库[没有任何改变]。
$result = curlGetWithHeaders("API URL", "Parameters for that URL");
$data = json_decode($result);
所以在$result
我可以看到html标签,但不是在$data
。 而var_dump($data)
表示它是string
。
响应是= {"array":{"id":1,"title":"Title","short_title":"abcd","description":"<ul><li>0</li><li>A</li><li>B</li><li>C</li><li>D</li>"}}
,并使用json_decode
我越来越描述为pasred HTML后。
deals] => Array ( [0] => stdClass Object ( [deal] => stdClass Object ( [id] => 1 [title] => title [short_title] => abcd [description] => 0 • A • B • C
附近的[此问题](http://stackoverflow.com/questions/3837435/decoding-html-tags-using-json-decode-function)。那里的选择答案不那么恒星,恕我直言。 –
感谢您的回复,这意味着我应该使用'str_replace'来替换''为'<''''''为'>' – Pranav
你能举一个例子吗? –