PHP explode () and implode () methods

Source: Internet
Author: User
Tags php explode

In PHP, strings and arrays are transferred to each other
Splitting a string into an array explode ()--(split in other languages)

Concatenate an array into a string implode ()

<?PHP$test= ' I am Tommy.huang '; $result 1=Explode(‘ ‘,$test); Print_r($result 1); Echo' <br>-------------<br> '; $result 2=Explode(‘,‘,$test); Print_r($result 2); Echo' <br>-------------<br> '; $test _array1=Array(        ' Apple ', ' pear ', ' orange ',    ); $test _array2=Array(        ' Apple ',    ); $result 3=implode('-A ',$test _array1); $result 4=implode('-A ',$test _array2); Print_r($result 3); Echo' <br>-------------<br> '; Print_r($result 4);

The results are as follows:

Attention:

The explode () function splits a string by a given flag, and if the string does not have the flag, the result is not split , as in the second row of the result;

The implode () function is a string that links the elements of an array to a given flag, and when the array has only one element, there is no connection effect , as in the fourth row of the result.

PHP explode () and implode () methods

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.