PHP explode () Array_diff () implode () three functions _php tutorial

Source: Internet
Author: User
Tags php explode
$STR = ' array 1, array 2, array 3, array 4 ';
$array = Explode (', ', $str); Depositing a regular string into an array

The explode () function splits the string into arrays.

Grammar
Explode (separator,string,limit) parameter description
Separator required. Specifies where to split the string.
string is required. The string to split.
Limit is optional. Specifies the maximum number of array elements that are returned.


$array = Array_diff ($array, Array (' Arrays 2 ')); Deletes an array item of the specified value

The Array_diff () function compares two or more arrays, and returns the keys and values in an array that are not present in the second array if the key or value in the first array does not appear in the second array.

Syntax
Grammar
Array_diff (Array1,array2,array3 ...)

Parameter
Parameter description
Describe
Array1 required. The first array is the array, the others would be compared with
Necessary parameters. Specify the first base array to participate in the comparison
Array2 required. An array to being compared with the first array
Necessary parameters. Specify a second array compared to the first array
Array3 Optional. An array to being compared with the first array
Optional parameters. Specify a third array compared to the first array


$str = Implode (', ', $array); To save an array as a regular string

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

Grammar
Implode (separator,array) parameter description
Separator is optional. Specifies what is placed between the elements of the array. The default is "" (an empty string).
Array required. An array to combine as a string.

Description
Although the separator parameter is optional. However, for backwards compatibility, it is recommended that you use two parameters.

Echo $str;


http://www.bkjia.com/PHPjc/445365.html www.bkjia.com true http://www.bkjia.com/PHPjc/445365.html techarticle $str = array 1, array 2, array 3, array 4, $array = Explode (,, $str);//Put the string into array explode () function to divide the strings into arrays. Grammar explode (Separator,string,li ...

  • Related Article

    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.