PHP Tutorial





Español Français 中文 Deutsch Portuguese Japanese nederlands
   
 
PHP Topics
Introduction Introduction
Syntax Syntax
Data Types Data Types
Operators Operators
Control Structures Control Structures
Functions Functions
Pre-defined Function Pre-defined Function
Calendar Functions Calendar Functions
Date and Time Date and Time
Array Functions Array Functions
Array List Array Functions List1
Array Function List Array Functions List2
Math Functions Math Functions
PHP MYSQL Functions PHP Mysql Functions
File Handling File Handling
Error Handling Error Handling
DB Size DB Size
PHP Mail PHP Mail
String Tokens String Tokens
String Functions String Functions
String Functions List String Functions List1
String Functions List2 String Functions List2
Session Functions Session Functions
Cookies Functions Cookies Functions
Form Variables Form Variables
Running PHP from JS Running PHP from JS
Array To JS Array To JS
JS Array Array to PHP
Encryption Encryption
Common Header Common Header
Forums Ask Your Doubts
Scraps More about PHP
Feedback Feedback
 




Php Arrays Key & Values Comparison


Tutorials »Php »

Topic

What is array_diff_assoc Function?



Explanation

The "array_diff_assoc" function is used to compute the difference of arrays Keys and Values and return the difference of arrays.

Syntax:
    array_diff_assoc(array1,array2,array3,....)

In the above syntax "array1" is the array to be compare with, "array2" is the array which is to be compared to, atleast two arrays should be there,"array 3" is optional.It returns all values of "array1" that is not present in any other array.

Example
    <?php
    $a = array( 'x' => 'x','y' => 'y','g' => 'g');
    $b = array( 'x' => 'x','y' => 'y',);
    print_r(array_diff_assoc($a,$b));
    ?>
Result:
    Array ([g] => g)

In the above example the two arrays "$a","$b" are compared, by default all values of the first array are taken, 'g' is the only value that is not in the array "$b", so its displayed as output.





A Note

Learn PHP programming language tutorial with simple and neat example. Hope you enjoy this free tutorial. Do give us your valuable feedback and suggestions on this online tutorial. This is a Copyright Content.

Other Links

web hosting