I\'m using a php function want to create a function to trim all unnecessary white spaces from a multi line string.
The regex that it\'s not working is the one tha
You need to /gm
instead of just /m
The code should become: (this code won't work, the update one will)
$patterns[] = ['/ +$/mg', ''];
Working example here: https://regex101.com/r/z3pDre/1
Update:
The g
identifier, don't work like this. We need to replace preg_match
with preg_match_all
Use the regex without g
, like this:
$patterns[] = ['/ +$/m', ''];