PHP implode () function

Source: Internet
Author: User
Tags php explode

What is the function of PHP implode ()?

The implode () function in PHP returns a string composed of array elements that, contrary to the PHP explode () function, is the PHP explode () function that splits another string with one string and returns an array of strings.

Understanding the function of the PHP implode () function, let's take a look at the syntax of the PHP implode () function and its example.

Grammar

1 implode(separator,array)

Detailed parameters:

Parameters Description
Separator Optional. Specifies what is placed between the elements of the array. The default is "" (an empty string).
Array Necessary. An array to combine as a string.

Note: the implode () function accepts two parameter orders. However, for historical reasons, explode () is not possible, and you must ensure that the separator parameter precedes the string parameter.

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

Example

To separate the array elements with different characters, the code is as follows:

12345678910 <?php$arrarray(‘Hello‘,‘World!‘,‘Beautiful‘,‘Day!‘);echoimplode(" ",$arr)."<br>";echoimplode("+",$arr)."<br>";echoimplode("-",$arr)."<br>";echoimplode("X",$arr);?>

Code Run Result:

"Related articles recommended"

1. PHP explode () function instance detailed

2. How to use the PHP explode () function

PHP implode () function

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.