home HOME

PHP Basic
PHP HOME
PHP Intro
PHP Install
PHP Syntax
PHP Variables
PHP String
PHP Operators
PHP If...Else
PHP Switch
PHP Arrays
PHP Looping
PHP Functions
PHP Forms
PHP $_GET
PHP $_POST

PHP Advanced
PHP Date
PHP Include
PHP File
PHP File Upload
PHP Cookies
PHP Sessions
PHP E-mail
PHP Secure E-mail
PHP Error
PHP Exception
PHP Filter

PHP Database
MySQL Introduction
MySQL Connect
MySQL Create
MySQL Insert
MySQL Select
MySQL Where
MySQL Order By
MySQL Update
MySQL Delete
PHP ODBC

PHP XML
XML Expat Parser
XML DOM
XML SimpleXML

PHP and AJAX
AJAX Introduction
XMLHttpRequest
AJAX Suggest
AJAX XML
AJAX Database
AJAX responseXML
AJAX Live Search
AJAX RSS Reader
AJAX Poll

PHP Reference
PHP Array
PHP Calendar
PHP Date
PHP Directory
PHP Error
PHP Filesystem
PHP Filter
PHP FTP
PHP HTTP
PHP Libxml
PHP Mail
PHP Math
PHP Misc
PHP MySQL
PHP SimpleXML
PHP String
PHP XML
PHP Zip

PHP Quiz
PHP Quiz

Selected Reading
Web Statistics
Web Glossary
Web Hosting
Web Quality

W3Schools Forum

Helping W3Schools

pixels

PHP array_intersect_ukey() Function


PHP Array Reference Complete PHP Array Reference

Definition and Usage

The array_intersect_ukey() function compares the keys in two or more arrays, checking for matches, before comparing the keys in a user-defined function, then returns an array with the keys and values from the first array, if the function allows it.

Syntax

array_intersect_ukey(array1,array2,array3...,function)

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
function Required. The name of the user-made function


Tips and Notes

Tip: You can compare the first array with one array, or as many as you like.

Note: Only the keys have to be the same to get a match, both in the automatic comparison and in the user-defined function.


Example 1

<?php
function myfunction($v1,$v2) 
{
if ($v1===$v2)
	{
	return 0;
	}
if ($v1>$v2)
	{
	return 1;
	}
else
	{
	return -1;
	}
}
$a1=array(0=>"Dog",1=>"Cat",2=>"Horse");
$a2=array(3=>"Rat",1=>"Bird",5=>"Monkey");
print_r(array_intersect_ukey($a1,$a2,"myfunction"));
?> 

The output of the code above will be:

Array ( [] => Cat )


Example 2

How to assign more than two arrays to the function

<?php
function myfunction($v1,$v2) 
{
if ($v1===$v2)
	{
	return 0;
	}
if ($v1>$v2)
	{
	return 1;
	}
else
	{
	return -1;
	}
}
$a1=array(0=>"Dog",1=>"Cat",2=>"Horse");
$a2=array(0=>"Rat",1=>"Bird",5=>"Monkey");
$a3=array(6=>"Dog",7=>"Donkey",0=>"Horse");
print_r(array_intersect_ukey($a1,$a2,$a3,"myfunction"));
?> 

The output of the code above will be:

Array ( [0] => Dog )


PHP Array Reference Complete PHP Array Reference


Learn XML with Stylus Studio XML Tools - Free Download!

Stylus Studio - The World's Best XML IDE   

Stylus Studio makes it easy to edit and validate XML, XSLT, DTD, XML Schema, XHTML, XPath, XQuery and Web Service applications.

Free XML video demonstrations will help you learn XML and become a W3C XML development master in just minutes!

Download a FREE Trial Now!



Jump to: Top of Page or HOME or Printer Friendly Printer friendly page

W3Schools provides material for training only. We do not warrant the correctness of its contents. The risk from using it lies entirely with the user. While using this site, you agree to have read and accepted our terms of use and privacy policy.

Copyright 1999-2007 by Refsnes Data. All Rights Reserved.

Validate Validate W3C-WAI level A conformance icon W3Schools was converted to XHTML in December 1999
SITE SEARCH
 
About W3Schools
W3Schools Forum
Web charting
Web based charting
for ASP.NET
WEB HOSTING
$15 Domain Name
Registration
Save $20 / year!
UK Domain Names
UK Web Hosting

Alojamiento Web
Buy UK Domain Names
Register Domain Names
Cheap Domain Names
Cheap Web Hosting
Best Web Hosting
Domain Name Registration
PHP MySQL Hosting
Top 10 Web Hosting
Web Hosting Providers
Web Hosting Company
WEB BUILDING
Convert HTML to XML
Website Templates
Flash Templates
Website Builder
Internet Business Opportunity
Custom Programming
Web Design Forum
Programming Forum
FREE Trial or Demo
Web Content Manager
Forms,Web Alerts,RSS
Free Thumbnail Maker
Free Video Tutorials
HTML Exam
SHOPPING
UK Wholesalers
UK Wholesale
Online Casinos
Batteries
ONLINE DEGREE
Advance Your Career
with Drexel University
Bachelor's & Master's
Tech Degrees ONLINE
US Web Design Schools
YELLOW PAGES
www.nettkatalogen.no
www.gulex.dk
www.gulex.se
www.gelbex.de

pixels