Re: Simple array problem

From: Date: Tue, 01 Jul 2008 12:58:27 +0000
Subject: Re: Simple array problem
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-276165@lists.php.net to get a copy of this message
Brian Dunning wrote:
I'm trying to add a number to a value in an array. Pretend I have this: $new_value = array('orange', 2); $arr = array(
    array('blue', 4),
    array('orange', 5),
    array('green', 6));
I want to add the new value to the existing matching array element, so I end up with this: $arr = array(
    array('blue', 4),
    array('orange', 7),
    array('green', 6));
Seems like it should be really simple but all the ways I can figure out to do it are too kludgey. What have you tried so far?
Wolf

« previous php.general (#276165) next »