Home > Backend Development > PHP Tutorial > A brief analysis of the new Array function in PHP4_PHP tutorial

A brief analysis of the new Array function in PHP4_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-13 17:25:58
Original
822 people have browsed it

The array class function of php4 has three new members;
They are: array_unique(), array_intersect() and array_diff().

As the names suggest, these three functions are very simple:

1. array_unique(array array) ------- Remove duplicate elements from the array and then return the array
eg:
$arr = array("a","b","c","b");
$arr = array_unique($arr);
var_dump($arr); -- --Show $arr only contains three elements "a", "b", "c"

2. array_intersect(array array1,array,array2 .....) ---- In array form Returns common elements in multiple arrays
eg:
$arr1 = array("a","b","c","d");
$arr2 = array("e" ,"f","b","a");
$arr = array_unique($arr);
var_dump($arr); ----Show $arr contains two elements "a", "b"

3. array_diff(array array1, array array2) ----- Returns the elements that array1 does not have compared to array2 in array form.
eg:
$arr1 = array("a","b","c","d");
$arr2 = array("e","f","b", "a");
$arr = array_unique($arr);
var_dump($arr); ----Show $arr contains two elements "c", "d" I feel php4 is more user-friendly

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/532008.htmlTechArticlephp4’s array class function has three new members; namely: array_unique(), array_intersect() and array_diff(). As the names suggest, these three functions are very simple: 1. array_...
Related labels:
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