开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜