replace blank lines in php

前端 未结 6 1337
执笔经年
执笔经年 2020-12-20 03:26

How do I remove multiple blank lines from a string. I have looked at the examples on stackoverflow and have tried to change my code accordingly but I am not getting the rig

6条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-20 04:20

    Using regular expressions works, but some people unfamiliar with regular expressions could get confused as to how you lay out your expression. Using the familiar trim command is simply a better choice in my opinion, but in the end I think trim would be faster because it doesn't need to evaluate the regular expression etc.

提交回复
热议问题