“Laravel Keyby” Code-Antworten

Sammlung Laravel Filter

$collection = collect([1, 2, 3, 4]);

$filtered = $collection->filter(function ($value, $key) {
    return $value > 2;
});

$filtered->all();

// [3, 4]
Relieved Raccoon

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",
         ]
         	]*/
Irfan

Ähnliche Antworten wie “Laravel Keyby”

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen