How would I get '123' to '1-2-3?

Discussion in 'PHP' started by x0x, Oct 11, 2009.

  1. #1
    Using the function explode? Could someone show me how please.
     
    x0x, Oct 11, 2009 IP
  2. kbluhm

    kbluhm Peon

    Messages:
    23
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    http://www.php.net/str_split
    http://www.php.net/implode
    
    $string = '12345';
    
    $string = str_split( $string );
    $string = implode( '-', $string );
    
    echo $string; // 1-2-3-4-5
    
    PHP:
     
    kbluhm, Oct 11, 2009 IP
  3. x0x

    x0x Well-Known Member

    Messages:
    510
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    110
    #3
    Thanks.

    EDit: nevermind. Thanks.
     
    Last edited: Oct 11, 2009
    x0x, Oct 11, 2009 IP