How to get maximum key value of array in PHP?By Hardik Savani | March 2, 2016 | | 900 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];
- How to set ANDROID_HOME environment variable in ubuntu?
- Laravel 5 - GEO chart example and demo using lavacharts package
- How to add CKEditor with image upload using KCFinder in PHP Example Code?
- How to resolve laravel 5 blank page on server?
- Crop, Resize, Frames etc on selected image in php using Aviary
- Codeigniter 3 - CRUD(Create, Read, Update and Delete) using JQuery Ajax, Bootstrap, Models and MySQL
- Laravel 5 - Example of Database Seeder with insert sample data
- Multi select autocomplete jquery example with code