Skip to content

Instantly share code, notes, and snippets.

@jsenin
Created February 1, 2016 11:11
Show Gist options
  • Save jsenin/4a9fbef36a0949b85e96 to your computer and use it in GitHub Desktop.
Save jsenin/4a9fbef36a0949b85e96 to your computer and use it in GitHub Desktop.
two ways to handle empty arrays
<?php
/**
* two ways to handle empty arrays
* */
ini_set('error_reporting', E_ALL);
error_reporting(E_ALL);
$foo = array('Establishment' => array());
if ( ! array_key_exists('Establishment', $foo ) || ! count ( $foo['Establishment'] ) )
echo "Foo no tiene establishments\n";
if ( empty($foo['Establishment'] ) )
echo "Foo esta empty\n";
@AlvaroCaste
Copy link

Spanglish :P

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment