ID:               23964
 Updated by:       [EMAIL PROTECTED]
 Reported By:      prof_moriarty at veryfast dot biz
 Status:           Wont fix
 Bug Type:         Feature/Change Request
 Operating System: Win98 se
 PHP Version:      4.3.2
 New Comment:

Think of it this way.  This is bug #23964, that's a lot of bugs.  I
can't speak for anyone else but know that Derick closes many bugs and
is constantly working to improve PHP.  Maybe he saw this report and
feels there are many more pressing needs than adding another array
function, especially one that can be done fairly easy in userspace. 
I'm not proposing anything here, but here's a version with some
checks:

function array_sum_multi($arr, $key) {
    if (!is_array($arr)) {
        return false;
    }
    $sum = 0;
    foreach ($arr as $info) {
        if (isset($info[$key]) && is_numeric($info[$key])) {
            $sum += $info[$key];
        }
    }
    return $sum;
}

Basically, if I were you, I wouldn't lose too much sleep over it, or
take it personally.  Also, you will notice that your request is a
duplicate of a preexisting feature request for this same feature, see
also:

http://bugs.php.net/bug.php?id=12028

It's the same idea but a different implementation (which one is
correct? ;), and it remains open...


Previous Comments:
------------------------------------------------------------------------

[2003-06-04 19:44:03] prof_moriarty at veryfast dot biz

you are a Humbug...
:(

I can't code in C, and i'm not planning on adding it to my repertouir
any time soon.

Maybe i should say that next time someone else makes a suggestion for
my online game. Tell them to write it themselves, and still turn it
away...

There goes me ever trying to be helpful with PHP's dev in the
future....

There should be more 'pollita's / MGF's and less Dereks in the
world...

Ungratefully. :(
Me

------------------------------------------------------------------------

[2003-06-04 11:35:50] [EMAIL PROTECTED]

blah blah, write a patch yourself if you want this sooo badly. But then
still, the chance of being it included in PHP is sli,.

------------------------------------------------------------------------

[2003-06-04 10:15:14] prof_moriarty at veryfast dot biz

Unless you hadn't noticed, there isn't really much 'multi-level'
functionality in PHP anyway!?!?! (as in the ability to manipulate them
easily).
Let's see what we can find:

array_multisort : great function.

that's really about it. Sure numerous other functions can mess with
them, but mostly you'd have to put them into a loop to actually get
through all the dimensions.
Even the noted 'array_sum' doesn't work with multi-dimensionals (or at
least i spotted a post somewhere in this bug collection that stated as
much).


When you say "would be much slower", Do you mean from a processing
front (several micro seconds), or from a coding front (in which case
any proposed function would be quicker than writing it yourself)?
If you mean by time, then i'd only have to guess (noting my lack of
knowledge of benchmarking and C/++) that the proposed function would
actually gain a speed boost from being written into PHP's core,
primarily because it requires a loop (and on each iteration, a little
more time would be gained over a PHP implementation).


As you can probably tell, i don't plan on abandoning this little
function without a fight, simply because it can be 'user implemented'
(which i recognise and appreciate is a criteria for inclusion).

------------------------------------------------------------------------

[2003-06-04 09:58:00] [EMAIL PROTECTED]

I also think we shouldn't add the multilevel functionality here, as
it's pretty easy to do in userspace (yes, array_sum() should have been
something for userspace too). All other functions you mentioned *can*
be done in userspace, but would be much slower.

------------------------------------------------------------------------

[2003-06-04 09:54:56] prof_moriarty at veryfast dot biz

Yes, but that's not the point.
array_sum can be done in user_space.
as can:
array_fill,
array_pad,
array_pop
array_push
array_rand
array_count_values

Indeed, most of the array_ function can be done with a couple of lines
of code.

i.e. array_push:
>From the manual!!!!:
"Has the same effect as: 

$array[] = $var;"


That's just ONE line of code, and an apricot could get in it's sleep.
:)


Noting that it was only the third attempt that got it even relatively
correct, it goes to show that it's not so simple... (i've been playing
with PHP for 2+ years, and the other wrong one was a @php.net type!!!)

So could someone _please_ unset this as 'won't fix' (seeing as i
can't), and reset to 'open?

Thanx

------------------------------------------------------------------------

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/23964

-- 
Edit this bug report at http://bugs.php.net/?id=23964&edit=1

Reply via email to