Skip to content

Instantly share code, notes, and snippets.

@MrMaksimize
Created April 11, 2012 16:57
Show Gist options
  • Save MrMaksimize/2360518 to your computer and use it in GitHub Desktop.
Save MrMaksimize/2360518 to your computer and use it in GitHub Desktop.
empty
<?php
$array_one = array('bird' => 'penguin');
$t1 = $array_one['bird']; //that's fine
$t2 = $array_one['mammal']; //doesn't exist, throws a notice
$t3 = empty($array_one['mammal']) ? NULL : $array_one['mammal']; //checks if mammal is empty, if it is, sets null, otherwise sets the value.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment