Explode and implodeimp in php

Source: Internet
Author: User
Explode, imp: php's explode and implode: explode functions are to use one string to split another string. Returns a split array. Let's see the basic usage of explode:; print_r ($ data); echo ;? & Gt; the program output is: Array ([0] & gt; [1] & gt; aa [2] & gt; bb explode. the function is to use one string to separate another string. Returns a split array.

Let's look at the basic usage of explode:

 ";print_r($data);echo "
";?>
Program output:

Array
(
[0] =>
[1] => aa
[2] => bb
[3] =>
)

We can see that the first and end x of the str string is interpreted as a space, and x in the middle splits the string into two halves. If there are multiple x in the middle, the extra x is interpreted as a space.

For example, set str to xaaxxxbbx.

The program output is:

Array
(
[0] =>
[1] => aa
[2] =>
[3] =>
[4] => bb
[5] =>
)

Explode also has an optional parameter limit.

The function of limplode is to convert a one-dimensional array into a string. its basic usage is as follows:

  'aa',    'b' => 'bb',    'c' => 'cc');$str  = implode('x', $data);echo $str;?>
Program output: aaxbbxcc

The first parameter is the connector. if it is a space, the output is aa bb cc. if the first parameter is not specified, the output is aabbcc.

The above introduces explode and implode in php, including explode and imp, and hope to help those who are interested in PHP tutorials.

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.