PHP: array_key_exists() function

PHP: Checks if the given key or index exists in an array

The array_key_exists() function is used to check whether a specified key is present in an array or not.

The function returns TRUE if the given key is set in the array. The key can be any value possible for an array index.


(PHP 4 and above)


array_key_exists(array_key, array_name)


Name Description Required /
array_key Value to check. Required Mixed*
array_name The specified array whose keys will be checked. Required Array

*Mixed: Mixed indicates that a parameter may accept multiple (but not necessarily all) types.

Return value

TRUE on success or FALSE on failure.

Value Type: Boolean


$array1=array("Orange" => 100, "Apple" => 200, "Banana" => 300, "Cherry" => 400);
if (array_key_exists("Banana",$array1))
echo "Array Key exists...";
echo "Array Key does not exist...";


Array Key exists.

Pictorial Presentation:

php function reference: array_key_exists() function

View the example in the browser

Practice here online :

See also

PHP Function Reference

Next: array_keys

PHP: Tips of the Day

Convert HTML + CSS to PDF

Important: Please note that this answer was written in 2009 and it might not be the most cost-effective solution today in 2019. Online alternatives are better today at this than they were back then.

Here are some online services that you can use:

  • PDFShift
  • Restpack
  • PDF Layer
  • DocRaptor
  • HTML to PDF Rocket

Have a look at PrinceXML.

It's definitely the best HTML/CSS to PDF converter out there, although it's not free (But hey, your programming might not be free either, so if it saves you 10 hours of work, you're home free (since youalso need to take into account that the alternative solutions will require you to setup a dedicated server with the right software).

Ref : https://bit.ly/384yytr