Home > Backend Development > PHP Tutorial > php-Arrays function-array_diff_assoc-calculates the difference of arrays with index check_PHP tutorial

php-Arrays function-array_diff_assoc-calculates the difference of arrays with index check_PHP tutorial

WBOY
Release: 2016-07-13 17:51:25
Original
1210 people have browsed it

array_diff_assoc() function calculates the difference set of arrays with index check

【Function】
This function will return an array,
This array contains all values ​​in array1 that are not in any other parameter array.
【Scope of use】
           >=4.3.0, php5
【Use】
array array_diff_assoc( array array1, array array2[,array...] )
           array1/required/array1
           array2/required/comparable array must have at least one
           array.../optional/array used for comparison
【Example】
[php]

          $arr1 = array( "key1" => "val1", "key2" => "val2" );
          $arr2 = array( "key1" => "val1", "key3" => "val2" );
          $arr3 = array( "key2" => "val2" );
            print_r( array_diff_assoc( $arr1, $arr2 ) );
            print_r( array_diff_assoc( $arr1, $arr3 ) );
            print_r( array_diff_assoc( $arr1, $arr2, $arr3 ) );
/*
Array
(
[key2] => val2
)
Array
(
[key1] => val1
)
Array
(
)
*/

Excerpted from zuodefeng’s notes

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/478199.htmlTechArticlearray_diff_assoc() function with index check to calculate the difference set of the array [Function] This function will return an array, the array Contains all parameters in array1 but not in any other parameter array...
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