Sorting multi dimentional array by a date value in PHP

So at work I had to make graphs showing a lot of different data, that is GROUP BY‘d on DATE(created_time) from MySQL The problem arise when there hasn’t been any action during a certain day, there will be a gap and it will make the graphs look might strange. My first solution was to just do the number table trick in the INSERT of the data, but this started to pose problems when I wanted to do more advanced things and aggregate some of my statistical data without storing it in the format that my graphs and number table trick can use it. So instead of copy paste the number table trick into every SELECT query that needed it, I wanted to break it out into a proper function.