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

Your name:

Reply:


Posted by Kimmo Laine on 08/31/06 07:31

"version2" <corbett.jarrod@gmail.com> wrote in message
news:1157008639.831749.155770@b28g2000cwb.googlegroups.com...
> 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

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 pδivittyvδ nettisarjis
spam@outolempi.net || Gedoon-S @ IRCnet || rot13(xvzzb@bhgbyrzcv.arg)

[Back to original message]


УдалСнная Ρ€Π°Π±ΠΎΡ‚Π° для программистов  •  Как Π·Π°Ρ€Π°Π±ΠΎΡ‚Π°Ρ‚ΡŒ Π½Π° Google AdSense  •  England, UK  •  ΡΡ‚Π°Ρ‚ΡŒΠΈ Π½Π° английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Π‘Π°ΠΉΡ‚ ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ Π² Π‘Ρ‚ΡƒΠ΄ΠΈΠΈ Π’Π°Π»Π΅Π½Ρ‚ΠΈΠ½Π° ΠŸΠ΅Ρ‚Ρ€ΡƒΡ‡Π΅ΠΊΠ°
ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ ΠΈ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° Π²Π΅Π±-сайтов, Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΊΠ° ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ½ΠΎΠ³ΠΎ обСспСчСния, поисковая оптимизация