PHP Array

Last Updated: December 22, 2021

In PHP there are two types of array

1 index array

2 associative array

PHP Array functions


Check whether the key exists in PHP associative array

$search_array = array('first' => 1, 'second' => 4);
if (array_key_exists('first', $search_array)) {
    echo "The 'first' element is in the array";

Count number of elements

echo count($colors);