Explode dilemma

  • (2 Pages)
  • +
  • 1
  • 2

15 Replies - 1523 Views - Last Post: 30 June 2009 - 01:32 PM Rate Topic: -----

#16 AdaHacker   User is offline

  • Resident Curmudgeon

Reputation: 463
  • View blog
  • Posts: 820
  • Joined: 17-June 08

Re: Explode dilemma

Posted 30 June 2009 - 01:32 PM

View PostShaneK, on 30 Jun, 2009 - 09:20 AM, said:

I imagine there's some regex code somewhere that could do it.... That, in combination with preg_split, could help you get what you want.

Yeah, with preg_split(), doing this is completely trivial:
$array = preg_split('/ +/', $str);

That will split the array the desired way on any number of spaces. Or, if you're so inclined, you can make a small adjustment to have it split on whitespace of any kind, including newlines and tabs:
$array = preg_split('/\s+/', $str);

Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2