How to get maximum key value of array in PHP?By Hardik Savani | March 2, 2016 | | 2225 Viewer | Category : PHP
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.2 and AngularJS CRUD with Search and Pagination Example.
- How to connect mysql database in node js with example?
- How to git force pull from remote branch ?
- iOS 7 style switches for checkboxes example using switchery JS
- How to get logged in user data in Laravel 5?
- Laravel 5 - where condition with two columns example code
- How to send mail using zoho smtp server in PHP Laravel?
- Laravel 5 - Generate Captcha code and Validation example using BotDetect package