本人不擅长写正则,正则部分 你自己看着写吧
步骤 1 首先测试整理products_short_description
1.1 定义一个 变量内容为 products_description 的某一个完整内容
1.2 用正则过滤掉不想要的东西, 将想要的东西整理好
注:这个做完 你已经完成很大一部分内容了
2 备份数据库表 products,将products复制成 products_test表。为了测试 不破坏products表
3 查询出products_test表内容 。获取到每行数据的时候 执行下 步骤1 的内容
4 将步骤一相关正确的结果 放置到一个数组中 产品id为key ,形成的正确结果为value
5 最终 遍历正确的数组。 执行更新 products_test 表
6 当确认 以上无误 ,那你就可以更改products 表了
直接使用str_replace()函数即可。
比如:
str_replace("","
语法str_replace(find,replace,string,count)
参数描述
find 必需。规定要查找的值。
replace 必需。规定替换 find 中的值的值。
string 必需。规定被搜索的字符串。
count 可选。一个变量,对替换数进行计数。
htmlspecialchars($Param);
传到另一个字段就不用说了吧
就是清楚掉html代码吧 用这个方法试试。
function SpHtml2Text($str)
{
$str =
preg_replace("/
$alltext = "";
$start = 1;
for($i=0;$i
if($start==0 && $str[$i]==">")
{
$start = 1;
}
else if($start==1)
{
if($str[$i]=="<")
{
$start = 0;
$alltext .= " ";
}
else if(ord($str[$i])>31)
{
$alltext .= $str[$i];
}
}
}
$alltext = str_replace(" "," ",$alltext);
$alltext = preg_replace("/&([^;&]*)(;|&)/","",$alltext);
$alltext = preg_replace("/[ ]+/s"," ",$alltext);
return $alltext;
}