Explode String by Any Whitespace

This one-liner function will turn a string into an array by its whitespace properly looking for full-width spaces and multi-byte whitespace characters.

$itemArray = preg_split("@[\s+ ]@u", trim($dataString));

Leave a Reply

Your email address will not be published. Required fields are marked *