PHP explode function explained, Phpexplode function _php Tutorial

Source: Internet
Author: User
Tags php explode

PHP explode function explained, Phpexplode function


This article reprinted address: http://www.manongjc.com/article/515.html

The PHP explode function uses one string to split the other string, and the split string is combined into an array, and the array is returned. This article introduces to you the basic syntax of the explode function and the use of examples, the need for code farmers can refer to.

Explode using one string to split another string

basic syntax for the EXPLODE function:

Array Explode  string $delimiter  string $string  $limit  ] )

The EXPLODE function returns an array of strings, each of which is a substring of string that is separated by the delimiter as a boundary point.

Explode parameter Description:

Name of parameter Description
Delimiter Have to. Delimited characters.
String Have to. The string that needs to be split.
Limit

Optional. If the limit parameter is set and is a positive number, the returned array contains a maximum of limit elements, and the last element will contain the remainder of the string. If the limit parameter is a negative number, all elements except the last-limit element are returned. If limit is 0, it will be treated as 1.

Explode return value:

This function returns an array of strings, each of which is a substring of string, separated by the delimiter as a boundary point.

If delimiter is an empty string (""), Explode () returns FALSE. If the value contained in the delimiter is not found in the string and a negative limit is used, then an empty array is returned, otherwise an array containing a single element of string is returned.

Explode instances:

 
  $pizza   =  "Piece1 piece2 piece3 piece4 piece5 piece6"$pieces  =  explode ("",  $pizza  echo  $pieces [0];  // Piece1 Echo  $pieces [1];  // Piece2?>

Run online

http://www.bkjia.com/PHPjc/1101863.html www.bkjia.com true http://www.bkjia.com/PHPjc/1101863.html techarticle php Explode function explained, Phpexplode function This article reprint address: http://www.manongjc.com/article/515.html PHP explode function uses one string to separate another string, After the split ...

  • 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.