note 103093 deleted from function.array-sum by danbrown

From: Date: Fri, 25 Mar 2011 12:05:04 +0000
Subject: note 103093 deleted from function.array-sum by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-178197@lists.php.net to get a copy of this message
Note Submitter: Anonymous ---- function sum($arg1 = null, $arg2 = null, $argN = null) { $result = 0; foreach(func_get_args() as $arg) $result += is_array($arg) || $arg instanceof ArrayObject ? call_user_func_array(__FUNCTION__, (array) $arg) : $arg; return $result; } echo sum(1, 2, 3, array(4, 5, 6, array(7, 8, new ArrayObject(array(1, 2, 3))))), "\n"; // Result - 42

« previous php.notes (#178197) next »