Tutorials Point


  Learning PHP
  Advanced PHP
  PHP Function Reference
  PHP Useful Resources
  Selected Reading

Copyright © 2014 by tutorialspoint



  Home     References     Discussion Forums     About TP  

PHP Function array_udiff_assoc()


previous

Advertisements

Syntax

array_udiff_assoc ( $array1, $array2 [, $array3 ..., $data_compare_func] );

Definition and Usage

Computes the difference of arrays with additional index check, compares data by a callback function and returns an array containing all the values from array1 that are not present in any of the other arguments.

Paramters

ParameterDescription
array1Required. Specifies an array.
array2Required. Specifies an array to be compared with the first array.
array3Optional. Specifies an array to be compared with the first array.
data_compare_funcRequired. The name of the user-made function.

Return Values

Returns an array containing all the values from array1 that are not present in any of the other arguments.

Example

Try out following example:

<?php
function call_back_function($v1,$v2) 
{
   if ($v1===$v2)
   {
	   return 0;
   }
   return 1;
}
$array1 = array("a"=>"orange","b"=>"apple","c"=>"mango");
$array2 = array("a"=>"orange","b"=>"mango","c"=>"apple");
print_r(array_udiff_assoc($array1,$array2,"call_bak_function"));
?> 

This will produce following result:

Array ( [b]=>apple [c] => mango )

previous Printer Friendly

Advertisements


  

Advertisements