Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想编写脚本,他的动作是将字符串从一点切割到另一点。
例如:
<div id="box" style="font-size:bold;height:30px;width:100px;border: 1px solid black">xx</div>
我希望脚本会削减所有样式。它会是这样的:
<div id="box">xx </div>
我该怎么做 ?
如果您只想替换样式属性,您可以这样做:
$str = '<div id="box" style="font-size:bold;height:30px;width:100px;border: 1px solid black">xx</div>'; $str = preg_replace('/ style=\"[^\"]*\"/', '', $str);