adds function that takes in a multi dimmensional array and flattens it into 1 array