0

Hi all,i tried to do some research regarding associated arrays in php,even manual on the php documentations,but can not find the answer,how do i print the smallest value and the associated key from the array?

Edited by LibraryCode

2
Contributors
3
Replies
14
Views
1 Year
Discussion Span
Last Post by diafol
1

Quick n dirty:

$array = ['me'=>10,'you'=>9, 'them'=>33];
asort($array);
$key = key($array);
$val = $array[$key];

echo "The key is '$key' and the value is '$val'";

Edited by diafol

0

Thank you. Just a quck question why is it lousy?Is the any other ways to do it?

0

Didn.t say lousy. Just said quick n dirty meaning in this instance that I just cobbled it.together quickly without thinking too much about it.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.