I need a function or some regex to split up spaces in a string but to treat an HTML tag as a word.
$str = 'one two <a href="">three</a> four';
$x = explode(" ", $str);
print_r($x);
/* Returns:
Array
(
[0] => one
[1] => two
[2] => <a
[3] => href="">three</a>
[4] => four
)
Looking for way to return:
Array
(
[0] => one
[1] => two
[2] => <a href="">three</a>
[3] => four
)
*/
Any ideas? Thanks
This is a bit simpler then the above, haven’t fully tested but give it a shot.
Here is another version that I tested for about 5 minutes that works a bit better: