Quoting Brian Dunning [EMAIL PROTECTED]:
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
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
At 9:35 AM +0100 7/1/08, Richard Heyes wrote:
Brian Dunning wrote:
Seems like it should be really simple but all the ways I can figure
out to do it are too kludgey.
It's rather easy:
for ($i=0; $icount($arr); $i++) {
if ($arr[$i][0] == $new_array[0]) {
$arr[$i][1] +=
Small correction:
Which is...?
--
Richard Heyes
Employ me:
http://www.phpguru.org/cv
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
On Tue, Jul 1, 2008 at 8:50 AM, Richard Heyes [EMAIL PROTECTED] wrote:
Small correction:
Which is...?
--
Richard Heyes
Employ me:
http://www.phpguru.org/cv
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Look at the link he
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
I think the problem is easier... and also the solutions doing a for
instead of foreach are not good solutions because if the array is not
index-consecutive the loop fails.
So, if you has an array with the colors as indexes and the integer value X
as the value for that position of the array,
At 1:50 PM +0100 7/1/08, Richard Heyes wrote:
Small correction:
Which is...?
--
Richard Heyes
You missed it a second time? :-)
It's not, new_array[], but new_value[].
Cheers,
tedd
--
---
http://sperling.com http://ancientstones.com http://earthstones.com
--
PHP General Mailing
Roberto Costumero Moreno wrote:
I think the problem is easier... and also the solutions doing a for
instead of foreach are not good solutions because if the array is not
index-consecutive the loop fails.
So, if you has an array with the colors as indexes and the integer value X
as the value for
You missed it a second time? :-)
My sight is awful - if you don't point it out, chances are I won't see it.
--
Richard Heyes
Employ me:
http://www.phpguru.org/cv
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
At 3:44 PM +0100 7/1/08, Richard Heyes wrote:
You missed it a second time? :-)
My sight is awful - if you don't point it out, chances are I won't see it.
--
Richard Heyes
I'm just as bad, I only saw the error after I tried to get your code to run.
I thought I had another way, but your's
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:
12 matches
Mail list logo