Php implode () function description, implode Function Description
What is the function of php implode?
In php, the implode () function returns a string composed of array elements. It is opposite to the php explode () function. The php explode () function is: use one string to separate another string and return an array consisting of strings.
After learning about the functions of the php implode () function, let's take a look at the syntax of the php implode () function and its example.
Syntax
1 |
implode(separator, array ) |
Parameters:
Parameters |
Description |
Separator |
Optional. Specifies the content to be placed between array elements. The default value is "" (Null String ). |
Array |
Required. Array to be combined as a string. |
Note: The implode () function accepts the order of two parameters. However, for historical reasons, explode () does not work. You must ensure that the separator parameter is prior to the string parameter.
Note: The separator parameter of the implode () function is optional. However, we recommend that you use two parameters for backward compatibility.
Example
Use different characters to separate array elements. The Code is as follows:
12345678910 |
<?php $arr = array ( 'Hello' , 'World!' , 'Beautiful' , 'Day!' ); echo implode( " " , $arr ). "<br>" ; echo implode( "+" , $arr ). "<br>" ; echo implode( "-" , $arr ). "<br>" ; echo implode( "X" , $arr ); ?> |
Code running result:
[Recommended related articles]
1. php explode () function example
2. How to Use the php explode () function