php - Laravel collection how to remove a specific key from all items? -


it sounded crazy simple me @ first can't find solution!

here collection :

collection {#433   #items: array:432 [     0 => array:5 [       "word_id" => 12218       "name" => "ordered"       "rank" => 12217       "is_real" => 1       "id" => 1     ]     1 => array:5 [       "word_id" => 12097       "name" => "one-dimensional"       "rank" => 12096       "is_real" => 1       "id" => 2     ]     2 => array:5 [       "word_id" => 19679       "name" => "watery"       "rank" => 19678       "is_real" => 1       "id" => 3     ]     .     .     . 

but want :

collection {#433    #items: array:432 [     0 => array:5 [       "name" => "ordered"       "id" => 1     ]     1 => array:5 [       "name" => "one-dimensional"       "id" => 2     ]     2 => array:5 [       "name" => "watery"       "id" => 3     ]     .     .     . 

how can done laravel collection? have change collection array , manipulation myself? how?

$collection = $collection->map(function ($item) {     return array_only($item, ['id', 'name']); }); 

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -