3 回答

TA貢獻(xiàn)1860條經(jīng)驗(yàn) 獲得超8個(gè)贊
您可以preg_replace在這里使用:
$input = "p.a {
font: 15px arial, sans-serif;
}";
$output = preg_replace("/\{/", " {", $input);
echo $input . "\n";
echo $output;
這打?。?/p>
p.a {
font: 15px arial, sans-serif;
}
p.a { <-- extra space here
font: 15px arial, sans-serif;
}

TA貢獻(xiàn)1818條經(jīng)驗(yàn) 獲得超8個(gè)贊
如果您唯一的興趣是在所有“{”之后添加一個(gè)空格,玩具可以輕松使用以下代碼:
$CSS = '.sample{
padding: 10px;
}';
echo 'Old CSS code: '.$CSS.PHP_EOL.PHP_EOL;
$cleanCSS = str_replace('{', '{ ', $css);
echo 'Clean CSS code: '.$cleanCSS;
此代碼打?。?/p>
Old CSS code: .sample{
padding: 10px;
}
Clean CSS code: .sample {
padding: 10px;
}
- 3 回答
- 0 關(guān)注
- 216 瀏覽
添加回答
舉報(bào)