Please wrap all code in the ‘code’ button to allow for easy reading.
As for the code you have posted. I don’t understand what $meta_value is. Is this a variable which you have defined above?
Perhaps you could explain the data you have and what you are trying to do in a clear way without any code, and I can help direct you to a solution.