PHP array_udiff_uassoc () फ़ंक्शन
उदाहरण
दो सरणियों की कुंजियों और मूल्यों की तुलना करें (तुलना के लिए दो उपयोगकर्ता-परिभाषित कार्यों का उपयोग करके) और अंतर वापस करें:
<?php
function myfunction_key($a,$b)
{
if ($a===$b)
{
return 0;
}
return ($a>$b)?1:-1;
}
function myfunction_value($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"=>"green","c"=>"green");
$result=array_udiff_uassoc($a1,$a2,"myfunction_value","myfunction_key");
print_r($result);
?>
परिभाषा और उपयोग
array_udiff_uassoc () फ़ंक्शन दो या अधिक सरणियों की कुंजियों और मानों की तुलना करता है, और अंतर लौटाता है।
नोट: यह फ़ंक्शन तुलना के लिए दो उपयोगकर्ता-परिभाषित फ़ंक्शन का उपयोग करता है; कुंजी का उपयोग पहले फ़ंक्शन में किया जाता है और मान का उपयोग दूसरे में किया जाता है!
यह फ़ंक्शन दो (या अधिक) सरणियों की कुंजियों और मानों की तुलना करता है, और एक सरणी लौटाता है जिसमें सरणी 1 से प्रविष्टियाँ होती हैं जो सरणी 2 या सरणी 3 आदि में मौजूद नहीं होती हैं ।
वाक्य - विन्यास
array_udiff_uassoc(array1, array2, array3, ..., myfunc_key, myfunc_value)
पैरामीटर मान
Parameter | Description |
---|---|
array1 | Required. The array to compare from |
array2 | Required. An array to compare against |
array3,... | Optional. More arrays to compare against |
myfunc_key | Required. The name of the user-defined function that compares
the array keys. A string that define a callable comparison function. The comparison function must return an integer <, =, or > than 0 if the first argument is <, =, or > than the second argument |
myfunc_value | Required. The name of the user-defined function that compares
the array values. A string that define a callable comparison function. The comparison function must return an integer <, =, or > than 0 if the first argument is <, =, or > than the second argument. |
टेक्निकल डिटेल
प्रतिलाभ की मात्रा: | एक सरणी देता है जिसमें array1 से प्रविष्टियां होती हैं जो किसी अन्य सरणी में मौजूद नहीं होती हैं |
---|---|
पीएचपी संस्करण: | 5+ |
पीएचपी ऐरे संदर्भ