Created
February 1, 2016 11:11
-
-
Save jsenin/4a9fbef36a0949b85e96 to your computer and use it in GitHub Desktop.
two ways to handle empty arrays
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Spanglish :P