开发者

get content between custom comment

开发者 https://www.devze.com 2023-02-14 16:27 出处:网络
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

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

精彩评论

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