PHP

PHP Menu

PHP

array_intersect_assoc() Function - Definition, Syntax, Parameters, Examples

Definition

The array_intersect_assoc() function compares the keys and values of two or more arrays, and return an array that contains the entries from array1 that are present in array2, array3, etc.

Syntax

array_intersect_assoc(array1,array2,array3, ...)

Parameters

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.

Example

<?php
$ages2 = array("Fred" => 22, "John" => 32, "Robin" => 28); $ages3 = array("Mark" => 23, "John" => 32, "Mike" => 36);
$result=array_intersect_assoc($ages2, $ages3); print_r($result);

Introduction

PHP Basics

PHP Advance

PHP OOP

PHP Functions and Methods