1// Here's our fruity array
2$fruits = ['apple', 'pear', 'banana'];
3
4// Use it in an `if` statement
5if (array_key_exists("banana", $fruits)) {
6 // Do stuff because `banana` exists
7}
8
9// Store it for later use
10$exists = array_key_exists("peach", $fruits);
11
12// Return it directly
13return array_key_exists("pineapple", $fruits);
1<?php
2$array1=array("Orange" => 100, "Apple" => 200, "Banana" => 300, "Cherry" => 400);
3if (array_key_exists("Banana",$array1))
4{
5echo "Array Key exists...";
6}
7else
8{
9echo "Array Key does not exist...";
10}
11?>
12