How to get minimum key value of array in PHP?By Hardik Savani | February 12, 2016 | | 649 Viewer | Category : PHP
Share this post:
Sometimes, you need to get minimum key value of your array but you try to get with loop and any function etc, but in bellow example you can see we can get smallest key value from our php array by using min() and array_keys(). So, let's try to use in your code this way:
$myArray = ['2'=>'Hey','4'=>'Hello','1'=>'Hi','3'=>'GH'];
$new_key = min(array_keys($myArray));
$new_val = $myArray[$new_key];
- Laravel 5 - Custom Helper Facade Class Example from scratch
- How to redirect route with querystring in Laravel 5?
- Bootstrap - Input multiple tags example using Tag Manager Jquery Plugin
- How to get Lat and Lon from google map API in Jquery PHP?
- How to make simple dependent dropdown using jquery ajax in Laravel 5?
- How to solve 'There are no commands defined in the "cashier" namespace' in Laravel 5
- Laravel 5.3 - How to create SEO friendly sluggable URL
- How to parse json in jquery ajax?