loc; } else { return ""; } } $data = array("points" => array()); $traceroute = ""; function traceroute() { global $data, $traceroute; $traceroute = shell_exec("traceroute google.com"); $first = true; foreach(preg_split("/((\r?\n)|(\r\n?))/", $traceroute) as $line){ if ($first) { $first = false; continue; } $ipgeo = explode(",", ip2geo(get_substring($line, "(", ")"))); $coordinates = array('x' => $ipgeo[0], 'y' => $ipgeo[1]); array_push($data['points'], $coordinates); } } function raw_output() { global $traceroute; echo json_encode($traceroute); } function json_output() { global $data; echo json_encode($data); } ?>