php项目里有些格式需要格式化又不想回去改程序只能在模板开工。
模板里得到数据是
The Main Fabric,Fabric1,Fabric2
需要用正则匹配添加html元素
<?php echo preg_replace('/([^,]+)[,]?/', '<li>$1</li>', App_Helper_ProductSystemExtend::getCatalogsName( unserialize($row_return[$i]['edit_catalogs']) )); ?>
这样就为每个元素 前后添加了HTML 代码是不是很方便。
» 版权所有:YaoLei's Blog » 正则表达式如此好用
» 本文链接:https://www.yaolei.info/archives/173