YouTip LogoYouTip

Func Array Uintersect Uassoc

PHP array_uintersect_uassoc() Function |

-- Learning is not just about technology, but also about dreams!

PHP Tutorial

PHP Tutorial PHP Introduction PHP Installation PHP Syntax PHP Variables PHP echo/print PHP EOF(heredoc) PHP Data Types PHP Type Comparison PHP Constants PHP String PHP Operators PHP If...Else PHP Switch PHP Arrays PHP Array Sorting PHP Superglobals PHP While Loop PHP For Loop PHP Functions PHP Magic Constants PHP Namespaces PHP OOP PHP Quiz

PHP Forms

PHP Forms PHP Form Validation PHP Form - Required Fields PHP Form - Validate Email and URL PHP Complete Form Example PHP $_GET Variable PHP $_POST Variable

PHP Advanced Tutorial

PHP Multidimensional Arrays PHP Date PHP Include PHP File PHP File Upload PHP Cookie PHP Session PHP E-mail PHP Secure E-mail PHP Error PHP Exception PHP Filters PHP Advanced Filters PHP JSON

PHP 7 New Features

PHP 7 New Features

PHP Database

PHP MySQL Introduction PHP MySQL Connect PHP MySQL Create Database PHP MySQL Create Table PHP MySQL Insert Data PHP MySQL Insert Multiple Data PHP MySQL Prepared Statements PHP MySQL Read Data PHP MySQL Where PHP MySQL Order By PHP MySQL Update PHP MySQL Delete PHP ODBC

PHP XML

XML Expat Parser XML DOM XML SimpleXML

PHP and AJAX

AJAX Introduction AJAX PHP AJAX Database AJAX XML AJAX Live Search AJAX RSS Reader AJAX Poll

PHP Reference Manual

PHP Array PHP Calendar PHP cURL PHP Date PHP Directory PHP Error PHP Filesystem PHP Filter PHP FTP PHP HTTP PHP Libxml PHP Mail PHP Math PHP Misc PHP MySQLi PHP PDO PHP SimpleXML PHP String PHP XML PHP Zip PHP Timezones PHP Image Processing PHP RESTful PHP PCRE PHP Available Functions PHP Composer

PHP Example AJAX Poll

PHP 5 Calendar Functions

Explore Further

  • Programming
  • Data Management
  • Development Tools
  • Scripting Languages
  • Web Service
  • Software
  • Programming Languages
  • Computer Science
  • Scripting
  • Web Design and Development

PHP array_uintersect_uassoc() Function

PHP Array Reference Complete PHP Array Reference

Example

Compare the keys and values of two arrays (using user-defined functions for comparison) and return the intersection:

<?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_uintersect_uassoc($a1,$a2,"myfunction_key","myfunction_value");
print_r($result);
?>

Run Example Β»


Definition and Usage

The array_uintersect_uassoc() function compares the keys and values of two (or more) arrays and returns the intersection.

Note: This function uses two user-defined functions for comparison; the first function compares the keys, and the second function compares the values!

This function compares the keys and values of two (or more) arrays and returns an intersection array, which includes all keys and values that are present in the compared array (array1) and also in any other parameter arrays (array2 or array3, etc.).


Syntax

array_uintersect_uassoc(array1, array2, array3..., myfunction_key, myfunction_value)
Parameter Description
array1 Required. The first array to compare with.
array2 Required. The array to compare with the first array.
array3,... Optional. Other arrays to compare with the first array.
myfunction_key Required. The name of the user-defined function that will be used to compare the array keys. A string defining a callable comparison function. If the first argument is <, =, or > the second argument, the comparison function must return an integer <, =, or > 0, respectively.
myfunction_value Required. The name of the user-defined function that will be used to compare the array values. A string defining a callable comparison function. If the first argument is <, =, or > the second argument, the comparison function must return an integer <, =, or > 0, respectively.

Technical Details

Return Value: Returns an intersection array, which includes all keys and values that are present in the compared array (array1) and also in any other parameter arrays (array2 or array3, etc.).
PHP Version: 5+

PHP Array Reference Complete PHP Array Reference

← Func Array UniqueFunc Array Keys β†’