Code: Select all
$str='
This is a string.
This should be left justified by removing whitespaces preceding it.
';
preg_replace('/^\s+/', '', $str);Does JSON play a part in this?
Moderator: General Moderators
Code: Select all
$str='
This is a string.
This should be left justified by removing whitespaces preceding it.
';
preg_replace('/^\s+/', '', $str);I don't expect that to work at all. $str doesn't begin with a space.babyskill wrote:Running this, works as expected.Code: Select all
$str=' This is a string. This should be left justified by removing whitespaces preceding it. '; preg_replace('/^\s+/', '', $str);
Code: Select all
echo preg_replace('/^\s+/m', '', $str);