I have a simple explode thing going here:

$parsed = explode(' ',$line);

It works for most of the line I place inside. It's only separating by spaces, nothing huge.
However, the line I pass into the function happens to have spaces that exceed 1 character in size.

I figure a regexp is the way to go, but I'm not quite getting the syntax:

$parsed = explode('[[:space:]]',$line);

So far, I'm not making it happen. help!

    explode() does not support regular expressions, but preg_split() does, e.g.:

    $parsed = preg_split('/ +/', $line); // one or more spaces
    

      or

      $parsed = preg_split('/ /', $line,-1,PREG_SPLIT_NO_EMPTY);
      

        I think I would choose Nog's solution, as this takes into account multiple spaces in one fell swoop. If there is a possibility of tabs between words, you can add some additional insurance by using /\s+/ (as \s is a short-hand character class for all whitespaces).

          Write a Reply...