How to Learn PHP implode ()

Source: Internet
Author: User

How to Learn PHP implode ()

Implode function understanding 1

The implode () function combines array elements into a string.

1. How to understand array elements;

2. Whether the array element is a target object;

3. Whether the purpose is to integrate into a string;

 

Implode function understanding 2

Syntax

Implode (separator, array)

1. Whether the implode parameter 1 separator is added to each key value of the array;

2. Whether the implode Parameter Two array is an array of objects;

 

Parameters

Description

 

Optional. Specifies the content to be placed between array elements. The default value is "" (Null String ).

Array is required. Array to be combined as a string.

Description

Although the separator parameter is optional. However, we recommend that you use two parameters for backward compatibility.

1. Is the separator parameter optional;

2. Required for implode parameter 2 arra;

 

 

Tips and comments

Note: implode () can receive two parameter sequences. However, explode () cannot be used for historical reasons. The separator parameter must be set before the string parameter.

 

 

 

Implode function 3

<? Php

$ Arr = array ('h', 'I', 'J', 'K! ');

Echo implode ('M', $ arr );

?>

Output result: Hm Im Jm K!

<? Php

$ Arr = array ('h', 'I', 'J', 'K! ');

Echo implode ('', $ arr );

?>

 

Output result: h I J K!

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.