Add semi-working solution to flatten multi-dimensional array