How to get maximum key value of array in PHP?By Hardik Savani | March 2, 2016 | | 673 Viewer | Category : PHP
Share this post:
Sometimes, you need to get maximum 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 biggest key value from our php array by using max() 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 = max(array_keys($myArray));
$new_val = $myArray[$new_key];
- Laravel 5 - Google reCaptcha code and Validation example using anhskohbo/no-captcha package
- Laravel 5 database backup using Laravel Backup Package
- How to integrate google map using gmaps.js in php example?
- Laravel 5.3 - Create Bootstrap Contact US Form using Form Request
- Laravel 5 import export to excel and csv using maatwebsite example.
- Laravel 5 - How to create custom error page with example
- How to change date format using date filter in AngularJS?
- How to add CKEditor with image upload using KCFinder in PHP Example Code?