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 字符串函数手册

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 through string connection

Return value

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

Parameter

Serial numberParameters and descriptions
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 "a1 is: '".implode("','",$a1)."'<br>";
   echo "a2 is: '".implode("','",$a2)."'<br>";
   echo "a3 is: '".implode("','",$a3)."'<br>";
?>
test see </›

output result-

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

PHP String 字符串函数手册