codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
<?php $prefix = '#someId'; $css = '#hello, .class{width:1px;height:1px;background-color:#AAA;} div{font-size:1px} input, a, span{padding:4px}'; $parts = explode('}', $css); foreach ($parts as &$part) { if (empty($part)) { continue; } $subParts = explode(',', $part); foreach ($subParts as &$subPart) { $subPart = $prefix . ' ' . trim($subPart); } $part = implode(', ', $subParts); } $prefixedCss = implode("}\n", $parts); echo $prefixedCss;
Private
[
?
]
Run code
Submit