3v4l.org

run code in 300+ PHP versions simultaneously
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> </head> <body> <form method="post"> <textarea name="data" style="width: 100%; height: 300px"></textarea> <input type="submit"> </form> <?php $data = isset($_POST['data']) ? $_POST['data'] : ""; if ($data) { function parse($text) { global $foundName; global $foundCoord; $foundName = array(); $foundCoord = array(); preg_replace_callback('#\<Placemark (.+?)\<\/name\>#msi', function($matches) { global $foundName; $ex = explode(">", $matches[1]); $foundName[] = end($ex); } , $text); preg_replace_callback('#\<coordinates\>(.+?)\<\/coordinates\>#msi', function($matches) { global $foundCoord; $foundCoord[] = $matches[1]; } , $text); return array("name" => $foundName, "coord" => $foundCoord);; } $d = parse($data); $res = ""; $counter = 0; foreach($d['name'] as $k => $v) { $name = $v; $point = explode(",", (string) $d['coord'][$k]); $out = "GMSMarker*marker" . $counter ++ . "= [[GMSMarker alloc] init]; \n"; $out .= "marker" . $counter . ".position = CLLocationCoordinate2DMake(" . $point[1] . "," . $point[0] ."); \n"; $out .= "marker" . $counter . ".title = @\"" . $name . "\"; \n"; $out .= "marker" . $counter . ".map = mapView_; \n"; $out .= "marker" . $counter . ".icon = [UIImage imageNamed:@\"wc.png\"]; \n \n"; $res .= $out; } echo '<textarea style="width:500px; height: 300px">' . $res . '</textarea>'; } ?> </body> </html>

preferences:
49.89 ms | 402 KiB | 5 Q