dongmozhui3805 2017-01-17 10:11
浏览 77

PHP - 如何从数据库中删除双引号?

I have store data in database text field like this :

<p><strong>Relish Scrumptious Dessert Delights with Baskin Robbins Gift
 Voucher</strong></p><span>good</span><div>any rendom text</div> and so on..

So now when I print this data in front end then it should be remove HTML tag only show main content of field but no, it's show me same data that I store in database because it's taking it as a string means when I'm fetching data from database it's add double quotes at beginning and end of the data so it's read as a string and show me same data as I have in database.

I check using inspect element and show that it adds double quotes automatically so for testing I have removed double quotes using inspect element and all data is showing correctly.

I tried to replace double quotes with space using jquery when page load but my actual data don't contain any double quotes so jquery function is not replacing anything.

I tried hard to explain my problem I hope you guys will understand my problem and someone let me know the solution for this weird problem that I'm facing.

UPDAT

BrandController.php

public function get_brand_api(){


$select = "SELECT
               b.*,
               GROUP_CONCAT(bp.p_name) AS price,
               GROUP_CONCAT(bp.p_skuId) AS sku,
               GROUP_CONCAT(bp.p_type) AS type,
               GROUP_CONCAT(bp.p_valueType) AS valuetype
               FROM
               brands AS b
               LEFT JOIN
               brand_price AS bp ON b.hash = bp.hash
               WHERE b.slug = :slug GROUP BY  b.brand_id
               ";
    $sth = $this->connection->prepare($select);
    $sth->bindParam(":slug", $slug);
    $sth->setFetchMode(PDO::FETCH_ASSOC);
    $sth->execute();
    $status = $sth->fetchAll();

    return $status;


}

brand_detail.blade.php

<div id="container_detail">
  <brand-detail></brand-detail>
</div>
<template id="brand-detail-template">
   <div class="content">
      <h1> @{{d.brand_name}} </h1>
      <img :src="d.image" class="">     
   </div>
    @{{d.description}} // HERE I AM GETTING HTML TAGS WITH DATA.
</template>

brand_detail.js

Vue.component('brand-detail', {

template: '#brand-detail-template',

data: function(){

return {

    detail: []

}

},

created: function(){
//var slug = this.$route.params.slug;
var slug = window.location.pathname.split("/").pop();
var url = window.location.protocol + "//" + window.location.host + "/";

var api_url = url + 'gift_india/brand_detail/' + slug;
var that = this
axios.get(api_url)
    .then(function (response) {
        //console.log(response.data);
        that.detail = response.data;

    })
    .catch(function (error) {
        console.log(error.data);
    });

    },

   filters: {
removehtml: function (value) {
    if (!value) return ''
    var myContent = value;
    return myContent.replace(/(<([^>]+)>)/ig,"");
},
strtoarr: function (value) {

    var array = JSON.parse("[" + value + "]");
    return array;
}


}



});



 new Vue({



 el: '#container_detail'



 })

above blade template code is related Vue js so there is some rendom tags and template.

  • 写回答

2条回答 默认 最新

  • doubi3929 2017-01-17 10:15
    关注

    You can use the strip tags function in case you want to remove the tags

    echo strip_tags($text);
    

    If you want to replace the double quotes, and consider it as HTML use the below code.

    $html = str_replace('"', '', $text);
    
    评论

报告相同问题?

悬赏问题

  • ¥30 vmware exsi重置后登不上
  • ¥15 易盾点选的cb参数怎么解啊
  • ¥15 MATLAB运行显示错误,如何解决?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题
  • ¥20 yolov5自定义Prune报错,如何解决?
  • ¥15 电磁场的matlab仿真
  • ¥15 mars2d在vue3中的引入问题
  • ¥50 h5唤醒支付宝并跳转至向小荷包转账界面