开发者

PHP Trim first 5 characters + semi-colon

开发者 https://www.devze.com 2022-12-21 06:25 出处:网络
Here is my string: usercss:body background: red, #header: background: #fff; I want to remove usercss: body background: red, #header: background: #fff;

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

精彩评论

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

关注公众号