Jump to: navigation, search

Php array uintersect assoc

From w3cyberlearnings

Contents

PHP function array_uintersect_assoc

This function compares two or more arrays with a user-defined functions.
This comparison is based on the first array. When the function returns 0, the array element will be return.

Syntax array_uintersect_assoc

  • array1: array input
  • array2: array input
  • array3: array input
  • callback: user-defined function
array_uintersect_assoc (array1, array2, array3, ..,callback);

Example 1

<?php

$score_name1 = array(30 => 'John3', 13 => 'Christ', 41 => 'Mark');
$score_name2 = array(31 => 'John', 41 => 'Christ', 41 => 'Mark');


$score = array_uintersect_assoc($score_name1, $score_name2, "strcasecmp");
print_r($score);
?>

Output

Array ( [41] => Mark )

Example 2

<?php

$score_name1 = array(30 => 'John3', 13 => 'Christ', 41 => 'Mark');
$score_name2 = array(31 => 'John', 41 => 'Christ', 41 => 'Mark');

function checkscore($k1, $k2) {
	if($k1 === $k2) {
		return 0;
	}
	else {
		return 1;
	}
}

$score = array_uintersect_assoc($score_name1, $score_name2, "checkscore");
print_r($score);
?>

Output

Array ( [41] => Mark )

Related Links


Navigation
Web
SQL
MISC
References