Hello, I have the following code.
foreach ($tickets->list as $key => $val) :
$data_fecha = date("Y-m-d",strtotime($val->data['fec_Emision']['valor']));
if($data_fecha == $data_fecha){
echo "se repite";
}
print_r("<pre>");
print_r($data_fecha);
print_r("</pre>");
endforeach;
The output is the following:
Of course it reaches today's current date which is 17.
And well what I want to achieve is that every time the date is repeated, I want the others to be eliminated and only one date remains for each query that is made
The query I make is simple and is as follows:
SELECT * FROM ticket WHERE `fec_Emision` >= '2022-10-00' AND `fec_Emision` <= '2022-11-00'ORDER BY `fec_Emision` ASC
And well what I want at the end of all this is that in my ChartJs bar chart it shows me day by day as in the following chart.
And the output I currently have is this
AID!
I think I understand what you need, although the approach of your query is very confusing.
I understand that if you make that query you have, it is because you use it for other things, not just getting the date, and you want to take advantage of it to get the dates without repetitions.
If so, I recommend something like this:
That should show you an array containing all dates without repeating any.
With that, you can now set up other loops by traversing
$fechas_sin_repeticion
or whatever you need to get other data for your graphs.If you have not understood something or my answer has nothing to do with what you want, tell me, thanks.