php explode() array_diff() implode() three functions_PHP tutorial

WBOY
Release: 2016-07-20 11:02:31
Original
1119 people have browsed it

$str = 'array1,array2,array3,array4';
$array = explode(',',$str); //Save regular string into array

The explode() function splits a string into an array.

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


$array = array_diff($array,array('array2')); //Delete the array item of the specified value

The array_diff() function compares two or more arrays. If the key or value in the first array does not appear in the second array, it will be returned in the form of an array. The key and value that appear.

syntax
Grammar
array_diff(array1,array2,array3...)

parameter
Parameter description
Description
array1 required. the first array is the array that the others will be compared with
Required parameters. Specify the first benchmark array to participate in comparison
array2 required. an array to be compared with the first array
Required parameters. Specifies the second array
to be compared to the first array array3 optional. an array to be compared with the first array
Optional parameters. Specifies the third array

to be compared with the first array


$str = implode(',',$array); //Save the array as a regular string

implode() function combines array elements into a string.

Grammar
implode(separator,array) parameter description
separator optional. Specifies what is placed between array elements. Default is "" (empty string).
array required. Arrays to be combined into strings.

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

echo $str;


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/445365.htmlTechArticle$str = array 1, array 2, array 3, array 4; $array = explode(,,$str ); //Save the regular string into the array. The explode() function splits the string into an array. Syntax explode(separator,string,li...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!