Hi all,
I need to make an array from string by more 1 space. I do it with code:
$subject = "
Line one Line Two Line Three LineLast
";
$result = preg_match_all("~(.+)\b(?:[\s]{2,}|$)~U", $subject, $matches);
It works, but I need to trim all elements inside of $matches :
$matches = preg_replace_callback($validPattern, array($this, "trimStringValue"), $subject, limit: -1);
public function trimStringValue($matches)
{
return trim($matches[1]);
}
But value of $matches after preg_replace_callback has concatanated string of all arrays in $subject,
but not array of trimmed lines as I need.
Why so and how that can be fixed ?
Thanks in advance!