I have the following code:
$dat[] = ["2016-11-09", 1];
$dat[] = ["2016-11-09", 1];
$dat[] = ["2016-11-15", 1];
$dat[] = ["2016-11-16", 1];
$dat[] = ["2016-11-16", 1];
$dat[] = ["2016-11-17", 2];
$fechaAnt="";
$repetidos=1; //agregado
for ($l=0; $l < count($dat); $l++) {
if($dat[$l][0]!=$fechaAnt || $fechaAnt==""){ //Si tu fecha es diferente a la anterior o es igual a vacio porque es la primera vez
$lineas=$dat[$l][1]; //inicia lineas
$hola[]= [$dat[$l][0],$lineas]; //Se asigna la la fecha y las lineas
}else if($dat[$l][0]==$fechaAnt){ //si tu fecha es igual a la anterior
$lineas=$lineas.",".$dat[$l][1]; //sigue concatenando
$hola[$l-$repetidos][1]= $lineas; //Se asigna solo la variable $lineas
$repetidos++;
}
$fechaAnt=$dat[$l][0]; //Asignas valor a la fecha anterior que es la que acabas de pasar
}
What it does is concatenate the numbers in case the date is repeated and when printing the JSON it throws something like this
echo json_encode($hola); // $hola es mi variable que tiene mi arreglo
0:["2016-11-09", "1,2"]
1:["2016-11-15", 1]
2:["2016-11-16", "1,4"]
3:["2016-11-17", 2]
and I need it to be as follows,
0:["2016-11-09", 1, 2]
1:["2016-11-15", 1]
2:["2016-11-16", 1, 4]
3:["2016-11-17", 2]
that in the values that are concatenated, remove the "", the problem is that I do not know how to do it Can someone help me?