note 56994 deleted from function.isset by sobak

From: Date: Sat, 10 Dec 2016 09:55:57 +0000
Subject: note 56994 deleted from function.isset by sobak
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-208418@lists.php.net to get a copy of this message
Note Submitter: Peter Beckman <beckman at purplecow dot com> ---- Based on the previous post, I've found this code even more useful: <?php function isset_sum(&$var, $val) { if (isset($var)) $var += $val; else $var = $val; } ?> Now instead of: <?php if (isset($foo[$bar][$baz][$fooz])) $foo[$bar][$baz][$fooz] += $count; else $foo[$bar][$baz][$fooz] = $count; ?> No more "Undefined variable" warnings, and you save your fingers and sanity! Thanks to the previous poster for inspiration.

« previous php.notes (#208418) next »