How to get maximum key value of array in PHP?By Hardik Savani | March 2, 2016 | | 831 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];
- Select only one checkbox at a time using Jquery
- Solved - Access Not Configured. Google+ API (truncated...) on google console developer
- How to check current password using hash check in Laravel 5.3?
- How to count number of files in directory PHP?
- Laravel 5.3 Image Upload with Validation example
- How to get url segment in Laravel 5?
- Laravel 5 create Custom Validation Rule example.
- How to redirect to external link with laravel 5?