Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to use implode() function in php ?

    • 0
    • 1
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 97
    Comment on it

    What is tht implode() function in php ?

    The implode() function basically utilized to join elements of an array with a string. So in other word we can say, it takes an array and returns a string.

    syntax of implode() function

    implode (separator, array_name) implode(separator,array)

    means there are two main important thing in implode() function

    1-separator

    2-array_name

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

    <?php  
    $address=array('Country Name', 'Province Name', 'City Name'); 
    //here  $address is a array_name
    $resuldata=implode("-", $address);  
    //here  $resuldata is a varible in which store array list 
     //now call implode() function with  "-" separator
    print ($resuldata);  
    echo '<br>';  
    $resuldata=implode(" ", $address); 
    //now call implode() function with  " " separator
    print ($resuldata);  
    ?>  
    

    so output will come following:

    1-when use "-" separator then output will come

    Country Name-Province Name-City Name

    2-when use " " separator then output will come

    Country Name Province Name City Name

 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: