Online Tutorials & Training Materials | STechies.com
Register Login

PHP implode() Function

|| 0

PHP implode() Function
Stechies

Description

The implode() function is a binary-safe function in PHP, which used to join elements of an array. It merges all the elements of an array and returns a string. 

Syntax

implode(separator, array)

Parameter

The implode() function takes two parameters one optional and one compulsory.

Parameter Type Description
separator (optional) string type

This parameter separates the elements of an array joined to form a string.

Default value: empty string

array (mandatory) array This parameter specifies the array whose elements are to be imploded (joined)

Notes:

  • PHP implode() accepts its parameter in either order.
  • The separator parameter in implode() function became optional in PHP version  4.3.0, but it is recommended to use atleast two-parameter for backward compatibility.

Return Value: 

This function returns a string containing all the elements of input array in the same order, along with separator(if specified).

Example