Today now in this article i will show you how to get minimum key value of array in php. Sometimes, we need to get the minimum key value of our array but we try to get this value with loop and any function etc, But now in bellow example we can see how can get smallest key value from our php array just by using min() and array_keys(). So, let’s start and try to use in our code this way:
$myArray = ['2'=>'Hey','4'=>'Hello','1'=>'Hi','3'=>'GH']; $new_key = min(array_keys($myArray)); $new_val = $myArray[$new_key]; print_r($new_val);
Thanks for read. I hope it help you. For more you can follow us on facebook.