$data = '<p> </p>
<p> </p>
<p>hello</p>
<ul>
<li> </li>
<li> </li>
</ul>
<p>hello</p>
<p> </p>
<p> </p>';
$regex = preg_replace('/^((<[a-z]+>)( )(<\/[a-z]+>))/','',$data);
$regex = preg_replace('/((<[a-z]+>)( )(<\/[a-z]+>))$/','',$regex);
echo $regex;
i am able to remove only single line of code at top and bottom, while the next line i can't able to remove.even i have tried this code also
$regex = preg_replace('/^((<[a-z]+>)( )(<\/[a-z]+>))*/','',$data);
$regex = preg_replace('/((<[a-z]+>)( )(<\/[a-z]+>))*$/','',$regex);
echo $regex;
my exact output want to be like this
<p>hello</p>
<ul>
<li> </li>
<li> </li>
</ul>
<p>hello</p>