$array) { foreach ($array as $key => $value) { if ($value['coordinates']['latitude'] + $value['coordinates']['longitude'] != 0) { $data[$value['location']]['coordinates'] = $value['coordinates']; $i = count($data[$value['location']]['movies']); $data[$value['location']]['movies'][$i]['id'] = $id; $data[$value['location']]['movies'][$i]['description'] = $value['description']; } } } foreach ($data as $key => $value) { $string = explode(', ', $key); $index[$key] = implode(', ', array_reverse($string)); } asort($index); foreach ($index as $key => $string) { $kml .= "\t\t\n"; $kml .= "\t\t\t\n"; $kml .= "\t\t\t\n"; $kml .= "\t\t\t\t\n"; $kml .= "\t\t\t\t\t\t\n"; $kml .= "\t\t\t\t\t\n"; } $kml .= "\t\t\t\t]]>\n"; $kml .= "\t\t\t\n"; /* $kml .= "\t\t\t\n"; $kml .= "\t\t\t\t" . $data[$key]['coordinates']['latitude'] . "\n"; $kml .= "\t\t\t\t" . $data[$key]['coordinates']['longitude'] . "\n"; $kml .= "\t\t\t\t0\n"; $kml .= "\t\t\t\t500\n"; $kml .= "\t\t\t\t0\n"; $kml .= "\t\t\t\t0\n"; $kml .= "\t\t\t\n"; */ $kml .= "\t\t\t\n"; $kml .= "\t\t\t\t" . $data[$key]['coordinates']['longitude'] . ',' . $data[$key]['coordinates']['latitude'] . ",0\n"; $kml .= "\t\t\t\n"; $kml .= "\t\t\n"; $i++; if ($i == 0) break; } $kml = substr($kml, 0, -1); header('Content-Type: application/vnd.google-earth.kml+xml kml'); header('Content-Disposition: attachment; filename=0xdb.kml'); echo << 0xdb 0 0 1000 $kml KML; ?>