How to get maximum key value of array in PHP?By Hardik Savani | March 2, 2016 | | 1458 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];
- How to Uninstall a Package in Laravel 5 Using Composer Command?
- How to get last record from MySQL table in Codeigniter?
- How to get current url with parameters in Laravel 5?
- How to upgrade node.js version in Ubuntu?
- Laravel 5 - Custom Helper Facade Class Example from scratch
- How to use DB transactions in laravel 5?
- How to create virtual host in ubuntu apache?
- Simple Add remove input fields dynamically using jquery with Bootstrap