php - stripping whitespace and limiting <br> in nl2br() -
here lot of whitespace <br> <br> <br> 3 br's many... want trim 2 <brs> in row how can strip out whitespace , limit <br> max of 2 in php? 1 <br> , 2 <br>'s in row acceptable. on 2 gets trimmed 2 <br>'s
use preg_replace. strip excess whitespace (limit 1 space @ time):
$string = preg_replace('/\s\s+/', ' ', $string); you can research on how remove excess tags, preg_replace operation using regular expressions.
Comments
Post a Comment