“Laravel Keyby” Kode Jawaban

koleksi filter laravel

$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

Jawaban yang mirip dengan “Laravel Keyby”

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya