Here is my code
$str="<div>this is the variable</div>";
I want to remove its html tag <div> without using strip_tags.
I need $str="this is the variable"
Because my server is not working with strip_tags.
I know it is possible with preg_replace. but i dont know regex.
So please suggest me the solution.
Thank you in advance.
This variant works also if the DIV tag contains attributes:
$str = '<div id="some_id">this is the variable</div>';
$str = preg_replace('/\<[\/]{0,1}div[^\>]*\>/i', '', $str);
echo $str;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With