PHP

PHP Menu

PHP

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

Definition

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

Syntax

array_diff_key(array1, array2, array3, ...)

Parameters

Parameter Description
array1 Required. The array to compare from.
array2 Required. An array to compare against.
array3 Optional. More arrays to compare against.

Example

<?php
$ages1 = array("Mark" => 22, "Jeff" => 32, "Mike" => 28); $ages2 = array("Rey" => 22, "Jeff" => 32, "Mike" => 28);
print_r(array_diff_key($ages1, $ages2));

Introduction

PHP Basics

PHP Advance

PHP OOP

PHP Functions and Methods