function to checks whether given key or index exists in the array – PHP

<?php
 $search_array = array('key1' => 17, 'key2' => 74);
 if (array_key_exists('key1', $search_array)) {
    echo "The key 'key1' exists ";
 }
 //The key 'key1' exists
?>
Share

Leave a Reply

Your email address will not be published. Required fields are marked *