How to get minimum key value of array in PHP?By Hardik Savani | February 12, 2016 | | 1263 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];
- How to redirect to external link with laravel 5?
- Bootstrap SweetAlert - Confirm dialog box model with yes and no option example
- Bootstrap - Show/Hide(toggle) Password input field using bootstrap-show-password.js Plugin
- Laravel 5 create Custom Validation Rule example.
- Laravel 5.3 - whereDate(), whereMonth(), whereDay() and whereYear() examples.
- How to remove comma from string in jquery with example ?
- How to upgrade node.js version in Ubuntu?
- How to clear log file using command in laravel 5 ?