PHP implode () and explode ()

Source: Internet
Author: User

1, the implode () function returns a string composed of array elements, function syntax: string implode (Separator,array), optional separator parameter, specifies what is placed between array elements, default is an empty string The array parameter represents an array to be combined into a string.

Instance:

1 <? PHP 2 $arr Array (' Hello ', ' world! ', ' I ', ' love ', ' shanghai! ' ); 3 Echo implode ("",$arr); 4 ?>

Output:

Hello world! I Love shanghai!

The 2,explode () function returns an array of strings that are separated by a string delimiter as a boundary point. function syntax: array explode (string $delimiter, String $string) $delimiter represents a split character on a boundary, $string a string representing the input.

1<?PHP2 $data= "Foo:*:1023:1000::/home/foo:/bin/sh";3 List($user,$pass,$uid,$gid,$gecos,$home,$shell) =Explode(":",$data);4 Echo $user;//Foo5 Echo $pass;// *6?>

Output:

Foo 2013

PHP implode () and explode ()

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.