A utility function to fill gaps in arrays
Here's a neat little helper function that allows you to fill any gaps in arrays. I've mostly used it when fetching analytics from a database and I don't want to bother filling in the gaps using SQL.
It can probably be improved a lot, but this is at least a working version.