Explode string by one or more spaces or tabs

How can I explode a string by one or more spaces or tabs?

Example:

A      B      C      D

I want to make this an array.


Answer

$parts = preg_split('/\s+/', $str);

Leave a Reply

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