PHP implode () function

Source: Internet
Author: User

Implode ()

Function Name: implode ()
Function category: string functions
Description: The connected array is a string.
Function example: implode ("|", $ array );
Function prototype: implode (string, array );
Parameter description:
String: A required parameter. It is a string used to connect to an array unit.
Array: A required parameter. Its value is an array used for connection.
Description: concatenates an array into a string using the specified string.
Example:

 

Code

<? Php
// Define an array
$ Array = array ("my", "Hometown", "in", "Far Away ");
// Concatenate an array without a specified string
$ String = implode ("", $ array );
// Display the connected Array
Echo $ string;
Echo "<br> ";
// Use | as the connection string
$ String = implode ("|", $ array );
// Display the connected Array
Echo $ string;
?>

 

 

Output result:

My hometown is far away
My | hometown | in | far away

 

Note: The implode () function can be used for binary file operations.

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.