PHP array_udiff_assoc() ফাংশন

উদাহরণ

দুই অ্যারের কী-নাম এবং কী-মান তুলনা করুন (কী-নাম তুলনা করার জন্য অন্তর্নিহিত ফাংশনগুলি ব্যবহার করুন, কী-মান তুলনা করার জন্য ব্যবহারকারী-নির্দিষ্ট ফাংশনগুলি ব্যবহার করুন) এবং মানবহীন অ্যারে ফিরিয়ে দেয়

<?php
function myfunction($a,$b)
{
if ($a===$b)
  {
  return 0;
  }
  return ($a>$b)?1:-1;
}
$a1=array("a"=>"red","b"=>"green","c"=>"blue");
$a2=array("a"=>"red","b"=>"blue","c"=>"green");
$result=array_udiff_assoc($a1,$a2,"myfunction");
print_r($result);
?>

চালু করুন

বিবরণ ও ব্যবহার

array_udiff() ফাংশন দুই (বা আরও বেশি) অ্যারের কী-নাম এবং কী-মান তুলনা করে একটি মানবহীন অ্যারে ফিরিয়ে দেয়

মন্তব্য:এই ফাংশন অন্তর্নিহিত ফাংশনগুলি ব্যবহার করে কী-নাম তুলনা করে, কিন্তু ব্যবহারকারী-নির্দিষ্ট ফাংশনগুলি ব্যবহার করে কী-মান তুলনা করে

এই ফাংশন দুই (বা আরও বেশি) অ্যারের কী-নাম এবং কী-মান তুলনা করে একটি মানবহীন অ্যারে ফিরিয়ে দেয়, যা তুলনা করা অ্যারেগুলিতে সমস্ত আছেarray1)中,but not in any other parameter array(array2 or array3 etc.) key names and key values.

ব্যাখ্যা

array_udiff_assoc() ফাংশন ফিরাস্তা array1 মূল ডাটাসেটে রয়েছে কিন্তু অন্যান্য অ্যারেগুলিতে নেই অংশ。

注意与 array_diff() and array_udiff() is that the key name is also used for comparison. Key names and key values are compared simultaneously. For example, "a"=>1 and "b"=>1 are two unequal elements.

The comparison of array data is performed using the callback function provided by the user. In this respect, it is different from array_diff_assoc() behavior is exactly the opposite, the latter is compared with the internal function.

array_udiff_assoc() function's myfunction The function specified by the parameter is used to compare whether elements are equal.myfunction The function takes two parameters to be compared. If the first parameter is less than the second parameter, the function returns a negative number, if the two parameters are equal, it returns 0, and if the first parameter is greater than the second, it returns a positive number.

Syntax

array_udiff_assoc(array1,array2,array3...myfunction)
Parameters Description
array1 Required. The first array to be compared with other arrays.
array2 Required. The array to be compared with the first array.
array3,... Optional. Other arrays to compare with the first array.
myfunction

Required. String value, defining the callable comparison function.

If the first parameter is less than or equal to or greater than the second parameter, the comparison function must return an integer less than or equal to or greater than 0.

Technical Details

Return Value: Returns the difference set array, which includes all elements in the compared arrays(array1)中,but not in any other parameter array(array2 or array3 etc.) key names and key values.
PHP Version: 5+