Alex Rivera | Logout

Explode string by one or more spaces or tabs

Asked 2009-11-24T21:12:57.907
168

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.

Edit
Report

2 Answers

390
$parts = preg_split('/\s+/', $str);
answered 2009-11-24T21:17:21.610
4

instead of using explode, try preg_split: http://www.php.net/manual/en/function.preg-split.php

answered 2009-11-24T21:17:42.280

Your Answer