note 128599 added to function.array-sum
| From: | sarosekvlad12 at gmail dot com | Date: | Fri, 09 Jun 2023 17:41:08 +0000 |
| Subject: | note 128599 added to function.array-sum | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-220556@lists.php.net to get a copy of this message | ||
If you have a case where your array has int in strings, it sums them up as if there were only int in
the array!
function sum_mix($a)
{
return array_sum($a);
}
var_dump(sum_mix([9, 3, '7', '3']));
Response will be int(22)
----
Server IP: 45.112.84.4
Probable Submitter: 80.90.13.130 (proxied: 94.180.80.24)
----
Manual Page -- https://php.net/manual/en/function.array-sum.php
Edit -- https://main.php.net/note/edit/128599
Del: integrated -- https://main.php.net/note/delete/128599/integrated
Del: useless -- https://main.php.net/note/delete/128599/useless
Del: bad code -- https://main.php.net/note/delete/128599/bad+code
Del: spam -- https://main.php.net/note/delete/128599/spam
Del: non-english -- https://main.php.net/note/delete/128599/non-english
Del: in docs -- https://main.php.net/note/delete/128599/in+docs
Del: other reasons-- https://main.php.net/note/delete/128599
Reject -- https://main.php.net/note/reject/128599
Search -- https://main.php.net/manage/user-notes.php