2016-02-26 51 views
0

嗨所以这是一个简单的问题,我还发现了其他的结果和答案,但我似乎无法弄清楚,为什么它不剥离HTML地带HTML

我有一个像这样每个循环

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和雄辩的数组中的每条评论存储到数据库中。

但它仍然保存我的这些滑稽chartacters意见,我存储的数据看起来像这样

<p><strong>Q:</strong> Why do you think Apple is doing this? Do you really think they're trying to hurt extension devs?</p> 

我想保存这

+1

看起来像' $ comment'已经像插入前一样,你需要调查已经编码的东西。一个wysiwyg编辑器?别的东西? –

回答

2

之前转义这些<p><strong>Q:</strong>尝试strip_tags(html_entity_decode($comment))