Alright so I have not exactly tested this with 3d data, but I’m 95% certain it will work. I decided to preg_replace out the commas and spaces instead of preg_replacing the numerical values for lat and lon. This should allow for three values per each point (x,y and z). I am still learning regex, so please pardon the hack. It looks really ugly, but it works.

In addition I am no longer using If Then case. From this point forward I will be using Switch case. It is easier on the eyes.

Next step: Extrude! Maybe off of M Value?

<a href=’’>wkt 2 kml</a>