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);
    
    评论

报告相同问题?

悬赏问题

  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥120 计算机网络的新校区组网设计
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据
  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等
  • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
  • ¥15 qt6.6.3 基于百度云的语音识别 不会改
  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单