Separating Data

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • J Huntley Palmer

    #1

    Separating Data

    I am getting data lines with data separated by these 5 characters:

    , : ; <TAB> <whitespace>

    eg. foo,bar:baz foobar

    I would like to extract foo bar baz nad foobar.

    How can I parse out the data between or separated by them?

    Thanks!
  • Bob Stearns

    #2
    Re: Separating Data

    J Huntley Palmer wrote:
    [color=blue]
    > I am getting data lines with data separated by these 5 characters:
    >
    > , : ; <TAB> <whitespace>
    >
    > eg. foo,bar:baz foobar
    >
    > I would like to extract foo bar baz nad foobar.
    >
    > How can I parse out the data between or separated by them?
    >
    > Thanks![/color]
    $array = preg_split("[,;:\t ]", $string, -1, PREG_SPLIT_NO_E MPTY);

    The last argument takes care of consecutive delimiters.

    See URL: http://php.benscom.com/manual/en/fun...preg-split.php

    Comment

    Working...