mardi 27 décembre 2016

How to add as key one value, as value something else?

I want to display months, but in key to add number of month and for value to add name month. I have this code but problem is that when i foreach that and dispay $key it always give me name. Any suggestion how can i fix this?

 $archive = [];
  $archive_current_year = Articles::where('approved',1)->whereBetween('created_at', [
      Carbon::now()->startOfYear(),
      Carbon::now()->endOfYear(),
    ])->get()->groupBy(function($item) {
        $archive[Carbon::createFromFormat('Y-m-d H:i:s', $item->created_at)->month] = Carbon::createFromFormat('Y-m-d H:i:s', $item->created_at)->formatLocalized('%B');

    return  $archive;
  });



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2izJX9N
via IFTTT

Aucun commentaire:

Enregistrer un commentaire