从 PHP 中的查询中删除 HTML
Strip HTML from a query in PHP
你好,这是一个简单的问题,我找到了其他结果和答案,但我似乎无法弄清楚为什么它不删除 HTML
我有一个像这样的 for each 循环
foreach($allData[$counter]['comments'] as $comment) {
$sentiment = SentimentAnalysis::decision($comment);
//store this in the DB to have access to the information at a later stage
RedditComments::create([
'comment' => strip_tags($comment),
'created' => date($allData[$counter]['created']),
'sentiment' => $sentiment,
'search_identifier' => $search_id,
'search_phrase' => $searchPhrase
]);
}
$counter ++;
}
这使用 Laravel 和 eloquent 将数组中的每个评论存储到数据库中。
但它仍然用这些有趣的字符存储我的评论,我存储的数据看起来像这样
<p><strong>Q:</strong> Why do you think Apple is doing this? Do you really think they&#39;re trying to hurt extension devs?</p>
我想在存储这个
之前转义这些 <p><strong>Q:</strong>
尝试strip_tags(html_entity_decode($comment))
你好,这是一个简单的问题,我找到了其他结果和答案,但我似乎无法弄清楚为什么它不删除 HTML
我有一个像这样的 for each 循环
foreach($allData[$counter]['comments'] as $comment) {
$sentiment = SentimentAnalysis::decision($comment);
//store this in the DB to have access to the information at a later stage
RedditComments::create([
'comment' => strip_tags($comment),
'created' => date($allData[$counter]['created']),
'sentiment' => $sentiment,
'search_identifier' => $search_id,
'search_phrase' => $searchPhrase
]);
}
$counter ++;
}
这使用 Laravel 和 eloquent 将数组中的每个评论存储到数据库中。
但它仍然用这些有趣的字符存储我的评论,我存储的数据看起来像这样
<p><strong>Q:</strong> Why do you think Apple is doing this? Do you really think they&#39;re trying to hurt extension devs?</p>
我想在存储这个
之前转义这些<p><strong>Q:</strong>
尝试strip_tags(html_entity_decode($comment))