Bladephp: Now with 8+ codeigniter, php, and laravel project 8+ php project From $37/Month From Rs. 2499/Month

PHP array_diff_assoc() Function

by
Category:php
php php array function
PHP array_diff_assoc() Function

The array_diff_assoc() function is used to compare an array against another array and returns the difference. Unlike array_diff() the array keys are also used in the comparison.

This function compares the keys and values of two (or more) arrays, and return an array that contains the entries from array1 that are not present in array2 or array3, etc.

Parameter Description
array1 The first array which will be compared with other arrays.
array2 Compared with the first array.
array3,... Compared with the first array.

Syntax

 array_diff_assoc(array1,array2,array3...);

Example

$array1=array("a"=>"Prince","b"=>"James","c"=>"Samuel","d"=>"Cooper");
$array2=array("a"=>"Prince","b"=>"James","c"=>"Samuel");
$result=array_diff($array1,$array2);
print_r($result);

Output

Array ( [d] => Cooper ) 

0 Comments


Html code work in comment box


Related Post