mardi 17 mai 2016

Sorting or collection or array according to index in laravel 5.1

I have the following collection in laravel:

Collection {#357 ▼
  #items: array:11 [▼
    "29-04-2016" => array:2 [▼
      "posTotal" => "100"
      "posCount" => 1
    ]
    "05-05-2016" => array:6 [▼
      "posTotal" => "11"
      "posCount" => 1
      "keyedTotal" => "120"
      "keyedCount" => 1
      "cashTotal" => "32"
      "cashCount" => 2
    ]
    "10-05-2016" => array:10 [▼
      "posTotal" => "67"
      "posCount" => 4
      "keyedTotal" => "22"
      "keyedCount" => 1
      "cashcardTotal" => "123"
      "cashcardCount" => 1
      "refundTotal" => "-50"
      "refundCount" => 1
      "cashRefundTotal" => "-10"
      "cashRefundCount" => 1
    ]
    "17-05-2016" => array:2 [▶]
    "06-05-2016" => array:2 [▶]
    "16-05-2016" => array:2 [▶]
    "22-04-2016" => array:2 [▶]
    "25-04-2016" => array:2 [▶]
  ]
}

Now i wanted to sort it by index but needs to convert it as per date.

For e.g. I wanted to show

 "17-05-2016" => array:2 [▶]
 "10-05-2016" => array:10 [▶]
"06-05-2016" => array:2 [▶]

and so on...

I've tried laravel's sort collection method and also tried php's ksort function converting collection to array. But it's taking it as a string.



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

Aucun commentaire:

Enregistrer un commentaire