【问题标题】:HTML parsing how to remove tags, attributes in mysql database [duplicate]HTML解析如何删除mysql数据库中的标签、属性[重复]
【发布时间】:2016-06-22 04:59:33
【问题描述】:

HTML解析如何去除mysql数据库中的标签、属性

 preg_match("/<td id=\"enrolment_number\".*td>/", $page, $eno);   
    $e_no=$eno[0];
    $e_no = mysqli_real_escape_string($conn,$e_no);
    preg_match_all("/<p>(.*)<\/p>/", $page, $matches);    
    $nm=$matches[0][0];    
    $mob=$matches[0][4];    
    $sql= "INSERT INTO `leads` (`S.No`, `Enrolment_No`, `Enrolment_TimeStamp`, `Aadhaar_No`, `Name`, `Mobile`, `Address`, `City`, `District`, `State`, `Pincode`, `Remarks`) VALUES (NULL, '$e_no', '$e_dt', '$a_no', '$nm', '$mob', '$add', '$cit', '$dis', '$state', '$pin', '')";

【问题讨论】:

  • 这样保存在mysql中。我想保存没有标签的数据,只有属性值真正的转义字符串不起作用。 0000/00138/59364 18/02/2014 16:45:29 430419478922 td>

    Jahir Mondal

    8609607

    House No. - N0088, Rajkuthi,

    Krishna Baza...

    Memari (m)

    巴达曼

    西孟加拉邦

    713

  • 使用 strip_tags("your html content"),它会给出没有标签的内容

标签: php html mysql html-parsing


【解决方案1】:

在php中使用strip_tags函数,

string strip_tags ( string $str [, string $allowable_tags ] );

其中$allowable_tags是可选的,你可以在其中传递允许的标签,

欲了解更多信息,请查看:http://php.net/manual/en/function.strip-tags.php

【讨论】:

    猜你喜欢
    • 2010-11-10
    • 2018-08-18
    • 2010-10-20
    • 2011-05-19
    • 2012-02-17
    • 2015-10-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多