Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 

This blog is part of 1 Tute Sets.

Tute Set 1
Tute set by aneesh.garg
1 Blogs
  • How to use explode() function in php ?

    • 1/1
    • 1
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 172
    Comment on it

    Firstly let us know why we use explode() function in php ?

    explode() function basically used for breaking a string into an array in php. explode() function is binary-safe in php.

    explode() function syntex is given bellow:

    explode(',',string,0)

    means there are three main important things in explode() function
    1-separator(',')
    2-string
    3-limit

    You can take reference form below example of explode() function in php.

    ?php
    $Colorstr = 'red,blue,pink,green';
    //here $Colorstr is a variable in which store all string of color name.
    
    // now call explode() and give 0 limit
    print_r(explode(',',$Colorstr,0));
    print "<br-->";
    
    //now call explode() and give positive limit 2
    print_r(explode(',',$Colorstr,4));
    ?>
    

    so when you will give limit 0 then output will come:

    Array (

    [0] => red blue,pink,green )

    and when you will give limit 4 then output will come:

    Array (
    
    [0] => red
    [1] => blue
    [2] => pink
    [3] => green
          ) 

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: