How to trim each line in a heredoc (long string) in PHP

后端 未结 4 2624
囚心锁ツ
囚心锁ツ 2021-02-20 14:23

I\'m looking to create a PHP function that can trim each line in a long string.

For example,



        
4条回答
  •  既然无缘
    2021-02-20 14:32

    function trimHereDoc($t)
    {
        return implode("\n", array_map('trim', explode("\n", $t)));
    }
    

提交回复
热议问题