PHP & how to trim white space on beginning and the end of each new line with September 17, 2017 September 17, 2017 $text = join("\n", array_map("trim", explode("\n", $text))); Share this: Click to share on X (Opens in new window) X Click to email a link to a friend (Opens in new window) Email Like this:Like Loading... Related Previous PostPHP easiest color swap for rows Next PostPHP & how to trim, replace tabs and extra spaces with single spaces