Explode string by one or more spaces or tabs

DarthVader picture DarthVader · Nov 24, 2009 · Viewed 150.7k times · Source

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

Ben James picture Ben James · Nov 24, 2009
$parts = preg_split('/\s+/', $str);