replace blank lines in php

前端 未结 6 1315
执笔经年
执笔经年 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:00

    also put a trim on it:

       function removeMultipleBlankLines(&$array) {
          return trim(preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", $array));
        }
    

提交回复
热议问题