Current Location: Home> Function Categories> implode

implode

Convert the value of a one-dimensional array into a string
Name:implode
Category:String
Programming Language:php
One-line Description:Returns a string composed of array elements.

Definition and usage

implode() function returns a string composed of array elements.

Note: implode() function accepts two parameter orders. However, due to historical reasons, explode() is not possible. You must ensure that the separator parameter is before the string parameter.

Note: The separator parameter of implode() function is optional. However, for backward compatibility, it is recommended that you use two parameters.

Note: This function is binary safe.

Example

Example 1

Combine array elements into strings:

 <?php
$arr = array ( 'Hello' , 'World!' , 'I' , 'love' , 'Shanghai!' ) ;
echo implode ( " " , $arr ) ;
?>

Try it yourself

Example 2

Separate array elements with different characters:

 <?php
$arr = array ( 'Hello' , 'World!' , 'I' , 'love' , 'Shanghai!' ) ;
echo implode ( " " , $arr ) . "<br>" ;
echo implode ( "+" , $arr ) . "<br>" ;
echo implode ( "-" , $arr ) . "<br>" ;
echo implode ( "X" , $arr ) ;
?>

Try it yourself

grammar

 implode ( separator , array )
parameter describe
separator Optional. Specifies the content placed between array elements. The default is "" (empty string).
array Required. Arrays to be combined into strings.
Similar Functions
  • Alias ​​of implode join

    join

    Alias​​ofimplode
  • Calculate a string of crc32 polynomials crc32

    crc32

    Calculateastringofcr
  • Convert string to uppercase strtoupper

    strtoupper

    Convertstringtoupper
  • Convert hexadecimal string to binary string hex2bin

    hex2bin

    Converthexadecimalst
  • Break string to a specified number of strings wordwrap

    wordwrap

    Breakstringtoaspecif
  • Remove spaces (or other characters) from the beginning and end of the string trim

    trim

    Removespaces(orother
  • Returns the formatted string vsprintf

    vsprintf

    Returnstheformatteds
  • Calculate the md5 hash value of a string md5

    md5

    Calculatethemd5hashv
Popular Articles