PHP array_intersect_ukey () फ़ंक्शन
उदाहरण
दो सरणियों की कुंजियों की तुलना करें (उपयोगकर्ता द्वारा परिभाषित कुंजी तुलना फ़ंक्शन का उपयोग करके), और मैचों को वापस करें:
<?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"=>"blue","b"=>"black","e"=>"blue");
$result=array_intersect_ukey($a1,$a2,"myfunction");
print_r($result);
?>
परिभाषा और उपयोग
array_intersect_ukey() फ़ंक्शन दो (या अधिक) सरणियों की कुंजियों की तुलना करता है, और मिलान लौटाता है।
नोट: यह फ़ंक्शन कुंजियों की तुलना करने के लिए उपयोगकर्ता द्वारा परिभाषित फ़ंक्शन का उपयोग करता है!
यह फ़ंक्शन दो या दो से अधिक सरणियों की कुंजियों की तुलना करता है, और एक सरणी लौटाता है जिसमें array1 से प्रविष्टियाँ होती हैं जो array2 , array3 , आदि में मौजूद होती हैं ।
वाक्य - विन्यास
array_intersect_ukey(array1, array2, array3, ..., myfunction)
पैरामीटर मान
Parameter | Description |
---|---|
array1 | Required. The first array is the array that the others will be compared with |
array2 | Required. An array to be compared with the first array |
array3,... | Optional. An array to be compared with the first array |
myfunction | Required. 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.1.0+ |
और ज्यादा उदाहरण
उदाहरण
तीन सरणियों की कुंजियों की तुलना करें (कुंजी की तुलना करने के लिए उपयोगकर्ता द्वारा परिभाषित फ़ंक्शन का उपयोग करें), और मिलान लौटाएं:
<?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"=>"black","b"=>"yellow","d"=>"brown");
$a3=array("e"=>"purple","f"=>"white","a"=>"gold");
$result=array_intersect_ukey($a1,$a2,$a3,"myfunction");
print_r($result);
?>
पीएचपी ऐरे संदर्भ