split string

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sang
    New Member
    • Sep 2006
    • 83

    split string

    I am new to php. My program is to split the give string seperated by comma.
    that is the

    input is $str = "mysql,php,java ,javascript,ect ";

    output we want is
    mysql
    php
    java
    javascript
    ect

    How can i do this.please help me to solve this program

    Thanks in Advance
    Sang
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    Use the PHP explode() function. See explode function.

    For your particular case you can program it like[php]$items = explode(',', $str);
    for ($i=0; $i<count($items ); $i++)
    echo $items[$i].'<br>';[/php]
    Ronald :cool:

    Comment

    Working...