How to convert multiple
tag to a single
tag in php

后端 未结 9 1269
执念已碎
执念已碎 2020-12-03 02:03

Wanted to convert






into


9条回答
  •  难免孤独
    2020-12-03 02:22

    User may enter many variants



    < br />


    < br>

    ...and more.

    So I think it will be better next

    $str = preg_replace('/(<[^>]*?br[^>]*?>\s*){2,}/i', '
    ', $str);

提交回复
热议问题