note 126825 added to function.array-sum

From: Date: Thu, 03 Feb 2022 19:19:51 +0000
Subject: note 126825 added to function.array-sum
Groups: php.notes 
Request: Send a blank email to php-notes+get-217578@lists.php.net to get a copy of this message
<?php //you can also sum multidimentional arrays like this; function arraymultisum(array $arr){ $sum=null; foreach($arr as $child){ $sum+=is_array($child) ? arraymultisum($child):$child; } return $sum; } echo arraymultisum(array(1,4,5,[1,5,8,[4,5,7]])); //Answer Will be //40 ?> ---- Server IP: 45.112.84.4 Probable Submitter: 80.90.5.135 (proxied: 103.83.164.145) ---- Manual Page -- https://php.net/manual/en/function.array-sum.php Edit -- https://main.php.net/note/edit/126825 Del: integrated -- https://main.php.net/note/delete/126825/integrated Del: useless -- https://main.php.net/note/delete/126825/useless Del: bad code -- https://main.php.net/note/delete/126825/bad+code Del: spam -- https://main.php.net/note/delete/126825/spam Del: non-english -- https://main.php.net/note/delete/126825/non-english Del: in docs -- https://main.php.net/note/delete/126825/in+docs Del: other reasons-- https://main.php.net/note/delete/126825 Reject -- https://main.php.net/note/reject/126825 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#217578) next »