How to remove key from array in Laravel 5?By Hardik Savani | July 7, 2016 | | 2027 Viewer | Category : Laravel
Share this post:
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'=>'email@example.com','password'=>'123456','confirm-password'=>'123456'];
$myArray = array_except($myArray,['confirm-password']);
- How to get hours difference between two dates in laravel?
- How to create and use Middleware in Laravel 5?
- How to rename column name foreign key constraint in MySql Query?
- Laravel 5.3 - Form Input Validation rules example with demo
- Laravel 5 mailchimp api integration from scratch with example
- Laravel 5 and Vue JS CRUD with Pagination example and demo from scratch
- Autocomplete with images and custom html code in Jquery UI?
- Laravel 5 - inner join with multiple conditions example using Query Builder