English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

PHP Basic Tutorial

PHP Advanced Tutorial

PHP & MySQL

PHP Reference Manual

PHP implode() Function Usage and Example

PHP String String Function Manual

The implode() function is used to return a string composed of array elements.

Syntax

string implode ( array $pieces )

Definition and Usage

It is used to concatenate array elements with a string

Return Value

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

Parameter

NumberParameters and Description
1

glue

Default is an empty string.

2

pieces

The array you want to convert.

Online Example

Try the following example to combine array elements into a string

<?php
   //Combine Array Elements into a String
   $a1 = array("1","2","3");
   $a2 = array("a");
   $a3 = array();
   
   echo ''1 is: ''".implode('','",$a1)."'<br>";
   echo ''2 is: ''".implode('','",$a2)."'<br>";
   echo ''3 is: ''".implode('','",$a3)."'<br>";
?>
Test and See‹/›

Output Result-

a1 is: ''1','2','3'
a2 is: ''a''
a3 is: ''

PHP String String Function Manual