How to Remove Key from Array in Laravel?

By Hardik Savani | July 7, 2016 | Category : Laravel

Sometimes, we require to delete specific key from array like we have password and confirm-password field but we don't require to store confirm-password field we have to drop that key from input array, At that time we always use unset() function of PHP pre-define.

But if you work on laravel then you can array helper function. we can remove multiple key from variable using array_except() of Laravel pre-define function. In bellow example you can understand very well.


$myArray = ['name'=>'HD','email'=>'','password'=>'123456','confirm-password'=>'123456'];

$myArray = array_except($myArray,['confirm-password']);


Hardik Savani
My name is Hardik Savani. I'm a full-stack developer, entrepreneur and owner of Aatman Infotech. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.
Follow Me: Github Twitter
***Do you want me hire for your Project Work? Then Contact US.