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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Tue May 07 20:01:32 2024 UTC