PHP Trim first 5 characters + semi-colon
Here is my string:
usercss:body background: red, #header: background: #fff;
I want to remove usercss:
body background: red, #header: background: #fff;
Then explode
by , (comma)
to produce a list like so:
body {
background: red;
}
#header {
background: #fff;
}
Might be tricky to get the curly brackets in {} but if somebody could help me explode it开发者_JAVA技巧 into a list like:
body background: red; #heeader background: #fff;
That would be a great help!
$content=substr($content,strlen('usercss:'));
$arr=split(",",$content);
As of PHP5.3 you can also use http://de.php.net/manual/en/function.strstr.php
$content = strstr($content, 'usercss', true);
instead of substr
.
精彩评论