我想轉換html文檔中的所有大小。所有與px的應該除以4.所以100px將變成25px。
例如:
<div style="height:100px;"></div>
應該成爲
<div style="height:25px;"></div>
這裏是一個PHP代碼我寫的。但它不起作用。
$content = "<div style=\"height:100px;\"></div>";
$regex = "#([0-9]*)px#";
$output = preg_replace($regex,"$1/4",$content);
我該怎麼辦?
使用preg_replace_callback。 – nhahtdh