How to get minimum key value of array in PHP?By Hardik Savani | February 12, 2016 | | 528 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];
- Mysql procedure with pagination in laravel 5?
- How to check file size when select multiple file validation using Jquery?
- How to copy to clipboard without flash in AngularJS ?
- How to get current url with parameters in Laravel 5?
- Simple Add remove input fields dynamically using jquery with Bootstrap
- Laravel 5.3 - Form Input Validation rules example with demo
- Laravel 5 - Dynamic Dependant Select Box using JQuery Ajax Example - Part 1
- How to get location information from ip address in Laravel ?