# newbie - add 15 to number in list

#### Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

•  Subject
• Author
• Posted on
Hi there,

I am outputing a list of 10 values.

10, 20, 30, 40, etc

I can add 15 to one of the values then reorder the values from smallest
to highest but i want to update every single value and assign it values
increamenting by 10

so after the update the second number of 20 and add 15 I get

10, 30, 35, 40

now i want to re output the values above as

10, 20, 30, 40

## Re: newbie - add 15 to number in list

version2 wrote:

do this \$arr = arr1 = array (.........);

or use \$arr[][] syntax

## Re: newbie - add 15 to number in list

not sure if i follow you

## Re: newbie - add 15 to number in list

But this last is just the same as the original. I don't see the
difference... Was this supposed to be 10, 30, 20, 40 ?

It would help if you could explain in detail what you are trying to achieve
with this, but basicly that would go like this:
\$foo = range(10,100,10);// create the list of numbers
\$bar = \$foo;
\$foo[rand()%sizeof(\$foo)]+=15;// add 15 to random element.
asort(\$foo); // Sort the changed array

// Print the sorted changed order using the
// original values that were copied to \$bar
foreach(\$foo as \$k => \$v)
echo \$bar[\$k] . ', ';

--
"Ohjelmoija  on  organismi  joka  muuttaa  kofeiinia  koodiksi" - lpk
http://outolempi.net/ahdistus/ - Satunnaisesti pivittyv nettisarjis
spam@outolempi.net || Gedoon-S @ IRCnet || rot13(xvzzb@bhgbyrzcv.arg)

## Re: newbie - add 15 to number in list

Hui Kimmo,

sorry for the confusion, once i have added 15 to one of the numbers and
it has been sorted from lowest to highest it will look like this.

10, 30, 35, 40

assuming that i added 15 to 20 giving me 35.

now take that list 10, 30, 35, 40 and give them all new values 10, 20,
30, 40

so a break down of before and after

10 = 10
30 = 20
35 = 30
40 = 40

i hope this helps

thanks

Kimmo Laine wrote:

ve

## Re: newbie - add 15 to number in list

In this case you could modify my original suggestion a bit:

\$foo = range(10,100,10);// create the list of numbers
\$bar = \$foo;
\$foo[rand()%sizeof(\$foo)]+=15;// add 15 to random element.
asort(\$foo); // Sort the changed array

// Print the sorted changed order using the
// original values that were copied to \$bar
foreach(\$foo as \$k => \$v)
echo \$bar[\$k] . ' = ' . \$v . '<br/>';

--
"Ohjelmoija  on  organismi  joka  muuttaa  kofeiinia  koodiksi" - lpk
http://outolempi.net/ahdistus/ - Satunnaisesti pivittyv nettisarjis
spam@outolempi.net || Gedoon-S @ IRCnet || rot13(xvzzb@bhgbyrzcv.arg)

## Re: newbie - add 15 to number in list

version2 wrote:

(Top posting fixed)

I'm with Kimmo on this.  These are just numbers - and what you're trying
doesn't make sense.  You're just changeling one number, reordering the
series then putting the original numbers back.  You get exactly the same
result with a lot less work by just echoing the original list.

Can you tell us what you're *really* trying to do?  Maybe that will help
us understand your question.

P.S. Please don't top post.  Thanks.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================