Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

count same datetimes in foreach and group them php

$matchs = DiraChatLog::where('status','=','Match')->whereBetween('date_access', [$request->from, $request->to])->get();
$array[] = [];
foreach ($matchs as $key => $match) {
 $day = substr($match->date_access, 0, 10);
 if(isset($array[$day])){
  $array[$day]++;
 }else{
  $array[$day] = 1;
 }
}

dd($array);
 
PREVIOUS NEXT
Tagged: #count #datetimes #foreach #group #php
ADD COMMENT
Topic
Name
7+9 =