• PHP Video Tutorials

PHP - Function Implode



Syntax

string implode ( array $pieces )

Definition and Usage

It is used to Join array elements with a string

Return Values

It returns a string containing a string representation of all the array elements in the same order.

Parameters

Sr.No Parameters & Description
1

glue

It contains the information about defaults to an empty string.

2

pieces

The array of strings to implode.

Example

Try out the following example

<?php
   $a1 = array("1","2","3");
   $a2 = array("a");
   $a3 = array();
   
   echo "a1 is: '".implode("','",$a1)."'<br>";
   echo "a2 is: '".implode("','",$a2)."'<br>";
   echo "a3 is: '".implode("','",$a3)."'<br>";
?>

This will produce following result − −

a1 is: '1','2','3'
a2 is: 'a'
a3 is: ''
php_function_reference.htm
Advertisements