How to get keys name from array using array helper in PHP Laravel ?

By Hardik Savani February 18, 2017 Category : PHP Laravel

Few days ago, I was working on my new Laravel 5.4 application and i require to get keys name from my array. i was thing how we can get it and laravel provide us for to do it. Finally i found array helper function in Laravel docs. There are several array helper function available for array.

I found array_keys() helper for getting keys name from our array. array_keys() will return array of keys. It could be easy to work with keys name in array. So in this example i want to share with you small example using array_keys() helper.

I created one route "myarraykeys" with my $myArray variable, and in this route i used array_keys() helper and get keys array.


Route::get('myarraykeys', function () {

$myArray = [

'name'=>'Hardik Savani',

'email'=>'[email protected]',



$myArrayKey = array_keys($myArray);






[0] => name

[1] => email

[2] => website


I hope it can help you...