preg_replace语法错误(新手用户)

时间:2016-02-12 14:00:06

标签: php

我有下面的代码开始从我的数据库中提取数据,我想插入下面​​的函数来处理“产品描述”

echo '<Product>
        <ID><![CDATA['.$row['ID'].']]></ID>
        <ProductName><![CDATA['.htmlspecialchars_decode($row['ProductName']).']]></ProductName>
        <ProductCode><![CDATA['.$row['ProductCode'].']]></ProductCode>
        <Category><![CDATA['.$row['Category'].' > '.$row['Category_sub_1'].']]></Category>
        <Price><![CDATA['.$row['Price'].']]></Price>
        <MarketPrice><![CDATA['.$row['MarketPrice'].']]></MarketPrice>
        <AvailableQty><![CDATA['.$row['AvailableQty'].']]></AvailableQty>
        <Condition><![CDATA['.$row['Condition_new'].']]></Condition>
        <Weight><![CDATA['.$row['Weight'].']]></Weight>
        <ShippingProductClass><![CDATA['.$row['ShippingProductClass'].']]></ShippingProductClass>
        <ImageURL><![CDATA['.$row['ImageURL'].']]></ImageURL>
        <ProductDescription><![CDATA['.htmlspecialchars_decode($row['ProductDescription']).']]></ProductDescription>
        </Product>
        ';
}}}

我在哪里放置:

function swearwords($word){
    $word = preg_replace('/\b(w{3,4}\.)*(?<!img\.|imgmgr\.)badword(\.com)*\b/iu', '', $word);
    return $word;
}

0 个答案:

没有答案