php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #14726 Array_sum destroys string values
Submitted: 2001-12-27 18:05 UTC Modified: 2001-12-28 21:24 UTC
From: coyote at i-hwy dot net Assigned:
Status: Closed Package: Arrays related
PHP Version: 4.0.5 OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: coyote at i-hwy dot net
New email:
PHP Version: OS:

 

 [2001-12-27 18:05 UTC] coyote at i-hwy dot net
I'm using PHP 4.04pl1 on a linux box.

Whenever I use the array_sum function on an array 
containing both string and numeric values, it does the sum 
of the numeric values properly, but turns all non-number  
values in the array into the value "0" (zero).

I tried creating a function that copied the array into 
another variable so that it would not be operating on the 
original... but mysteriously, it still destroyed the string 
values in the _original_ array!

I don't have access to upgrade to a newer version of PHP... 
but if I were able to convince someone to upgrade, would 
that particular problem be fixed?

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-12-27 18:50 UTC] mfischer@php.net
This behaviour has been changed in 4.0.6 (the passed array is no longer modified). I've added a note to the documentation.

Thanks for the report. Closing.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu May 08 05:01:28 2025 UTC