How to get maximum key value of array in PHP?By Hardik Savani | March 2, 2016 | | 1668 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 after login, redirect back to previous url ?
- How to remove specific value from php array?
- Laravel 5 - Class 'Input' not found issue?
- How to get ckeditor value with tags on ajax-submit ?
- How to implement Email Verification with Activation Code example from Scratch in Laravel 5.2 ?
- How to find day from specific date in PHP?
- Laravel 5 Repository Pattern Tutorial from scratch
- How to use elasticsearch from scratch in laravel 5?