How to get minimum key value of array in PHP?By Hardik Savani | February 12, 2016 | | 1082 Viewer | Category : PHP
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];
- Codeigniter - Dynamic dependent dropdown using jquery ajax Example
- How to execute mysql query in laravel?
- Laravel 5 - GEO chart example and demo using lavacharts package
- Laravel 5 manual pagination with array example
- Laravel 5 select with sum query example
- How to merge two array with same keys without loop in PHP ?
- How to use where clause with mysql function in Laravel 5?
- How to get Ip Address in Codeigniter?