How to get minimum key value of array in PHP?By Hardik Savani | February 12, 2016 | | 489 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.3 - Customize pagination templates example from scratch
- Twitter Bootstrap - Digital Clock picker with AM PM example using clockface plugin
- How to create Pagination using dirPagination directive in Angularjs example with demo ?
- How to create and use Middleware in Laravel 5?
- Laravel 5 amazon s3 file upload tutorial - Part 2
- How to get year, month and day from timestamp date using carbon in Laravel 5?
- Bootstrap year picker example using datepicker js
- How to send mail using mailable in laravel 5.3?