list...Elliminating values to the right of a comma

Discussion in 'PHP' started by IamNed, Jul 27, 2011.

  1. #1
    i have a long two column list separated by a comma like this:

    fefewfewf,efewfew
    eeeeee,ggggg
    rgrgrr,gggrrrr

    i want to eliminate the values to the right of the comma for each column so it looks like:

    feferfef,
    ferferer,
    rgrgergrt,

    how is this done with php?
     
    IamNed, Jul 27, 2011 IP
  2. MRFD

    MRFD Active Member

    Messages:
    31
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    93
    #2
    You can use the explode function. See www.php.net/manual/en/function.explode.php
     
    MRFD, Jul 27, 2011 IP
  3. suryawl

    suryawl Peon

    Messages:
    54
    Likes Received:
    3
    Best Answers:
    1
    Trophy Points:
    0
    #3
    $temp = explode(",", "fefewfewf,efewfew");

    $new = $temp[0] . ",";
     
    suryawl, Jul 27, 2011 IP