vendredi 26 octobre 2018

group and count array php

I have an array which contains another array values: Ex.

array:69 [▼
  0 => array:9 [▼
    "app" => "a.log"
    "context" => "local"
    "level" => "error"
    "level_class" => "danger"

I want to group all the error according to their levels Ex:

array:
   "error" => "count of Errors",
   "debug" => "count of debug"

I tried doing this:

foreach($logs as $log){
        $result[$log['level']] = $log;                    
}

The result i get is:

array:2 [▼
   "error" => "Last error entry in array"
   "failed" => "Last failed entry in array"
]

Any help is appreciated. Thank You.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire