Skip to content

Instantly share code, notes, and snippets.

@YurePereira
Created March 2, 2017 15:45
Show Gist options
  • Select an option

  • Save YurePereira/41b1fba0c5d92cd532ebd34db7816992 to your computer and use it in GitHub Desktop.

Select an option

Save YurePereira/41b1fba0c5d92cd532ebd34db7816992 to your computer and use it in GitHub Desktop.
Verificando se uma chave existe dentro de um Array em PHP.
<?php
$listFrults = array(
'p' => 'Pineapple',
'c' => 'Cashew',
'a' => 'Apple',
'o' => 'Orange'
);
if (array_key_exists('a', $listFrults)) {
echo 'Chave existente.';//Bloco que será apresentado.
} else {
echo 'Chave não existente.';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment