Reply to Re: how to get lowest value

Your name:

Reply:


Posted by Kimmo Laine on 10/18/06 10:15

<jayipee@gmail.com> wrote in message
news:1161134572.618837.75610@m7g2000cwm.googlegroups.com...
> hi to all. can anybody help me figuring out how to get the minimum
> value from this list.
>
> log1 354
> log2 232
> log3 155
>
> from the above list i want to have a return value "log3" since this is
> the lowest value in the list.
>
> I tried to use $test = min(array('log1' => 354,'log2' => 232,'log3' =>
> 155));
> but it returns only the value 155 and not log3


$array = array('log1' => 354,'log2' => 232,'log3' => 155);
$test1 = array_search(min($array), $array);
$test2 = array_keys($array, min($array));

The difference between aray_search and array_keys is that _keys returns an
array of keys for matching elements. That means if several minimum values
are found, all matching elements are returned. Array_search just returns the
first.

--
"Ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" - lpk
http://outolempi.net/ahdistus/ - Satunnaisesti pδivittyvδ nettisarjis
spam@outolempi.net | 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

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