开发者

get content between custom comment

I have a html string. In that I defined some 开发者_C百科area for editing. That area enclosed in certain comment. I want to get all the content between that comment. For example

<!--start--> some content with any html tag <!--end-->

In the above example I need the content between the start and end tag. That is want

some content with any html tag.

-Arun


$string = '<!--start--> some content with any html tag <!--end-->';
preg_match('/<!--start-->(.*?)<!--end-->/', $string, $matches);

var_dump($matches);


$string = '<!--start--> some content with any html tag <!--end-->';
echo preg_replace('/<!--start--> (.*) <!--end-->/', '$1', $string);
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜