Array Diff Ukey Function In PHP

In this article I explain the PHP array_diff_ukey function.
  • 1501

Introduction

The array_diff_ukey function compares the key in two or more array, checking for differences, before comparing the keys in a user-defined function, returns an array containing all the entries from array1 that are not present in any of the other arrays.

Syntax

array_diff_ukey(array1,array2,array3...........userDefined function)

Parameter in array_diff_ukey Function

Parameter Description
array1 It specifies an array, who is compare from others.
array2 It  specifies an array to compare against.
.................. It specifies more array to compare against.
userDefined function It specifies name of user define function.

Example of array_diff_ukey Function

<?php

function myfunction($array1,$array2)

{

if ($array1===$array2)

  {

  return 0;

  }

if ($array1>$array2)

  {

  return 1;

  }

else

  {

  return -1;

  }

}

$array1 = array("a" => "Apple", "b" => "Mango", "c" => "Orange", "Banana");

$array2 = array("a" => "Apple", "b"=>"Raspberry", "banana");

echo "<pre>";

$result = array_diff_ukey($array1, $array2, "myfunction");

print_r($result);

?>

Output

array-diff-ukey-function-in-php.jpg

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.