How to check a key exist in an array

PHP array_key_exists() Function is used to check a key exist or not in an array.

<?php

$a = array( "language"=>"PHP","texteditor"=>"VScode" );

if ( array_key_exists( "language", $a ) )
  {
  echo "Array Key exists!";
  }
else
  {
  echo "Array Key does not exist!";
  }
  
?>

Leave a Comment