Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

Laravel KeyBy

$collection collect([
     ['name'=>'Twitter','valuation'=>'$13B'],
     ['name'=>'Facebook','valuation'=>'$522B'],
});
$collection->keyBy('name')->all();
   /*   [
      "Twitter"=>[
         "name"=>"Twitter",
         "valuation"=>"$13B",
      ],
      "Facebook"=>[
         "name"=>"Facebook",
         "valuation"=>"$522B",
         ]
         	]*/
 
PREVIOUS NEXT
Tagged: #Laravel #KeyBy
ADD COMMENT
Topic
Name
5+6 =