php - Finding the minimum value's key in an associative array -


Say in PHP that you have an associative array like this:

  $ pets = Array ("cats" => 1, "dogs" => 2, "fish" => 3);  

How can I find the key with the lowest price? Here, I'll search for cats .

Is it built in some function functions that I remember who does this? It would be great if there is a solution that is similar to many values, as given below:

  $ pets = array ("cats" => 1, "dogs" = & Gt; 1, "Fish" => 2);  

Above me, it does not matter that this is just the output; Cats or Dogs .

Thanks in advance.

is your friend:

  $ pets = array ("cats "= & Gt; 1," Dogs "=> 2," fish "=> 3); Array_kiss ($ pets, minimum (pets $); #AAR ('cats')  

PS : Here's a guideline where (at max instead of minimum , but I can remember it).


Comments

Popular posts from this blog

MySql variables and php -

url rewriting - How to implement the returnurl like SO in PHP? -

Which Python client library should I use for CouchdB? -