NYCPHP Meetup

NYPHP.org

[nycphp-talk] Handling empty values in hashes

Daniel Convissor danielc at analysisandsolutions.com
Thu Jul 17 14:17:49 EDT 2008


Paul:

> $value=$array[$key]

One right way to do this is:

if (array_key_exists($key, $array)) {
   // Life is good.
   $value = $array[$key];
} else {
   // Erm, it doesn't exist.  Now what?
   // Typically either set to NULL or throw error.
}

--Dan

-- 
 T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
            data intensive web and database programming
                http://www.AnalysisAndSolutions.com/
 4015 7th Ave #4, Brooklyn NY 11232  v: 718-854-0335 f: 718-854-0409



More information about the talk mailing list