tags:

views:

41

answers:

1

I have a string of tags that are usually separated by a single space, but the spacing may be inconsistent due to user input, hence the multiple spaces I added.

$somestring = "<h1> <a>   <h5> <img> <a> <strong>";

I'd like to store the tags into an array instead for easier manipulation. How can this be done with PHP?

+3  A: 

Using preg_split:

$array = preg_split("/\s+/", $somestring);
Ben Rowe
Argh, 2 seconds... ;)
deceze