maxudaskin Posted October 30, 2010 Share Posted October 30, 2010 I have the current code: $coord = preg_replace('"([0-9]{2}|[0-9]{3})([0-9]{2})([nNeS])([0-9]{3})([0-9]{2})([eEsW])"', '\\1\.\\2 \\3,\\4\.\\5 \\6', $coord); $coord = explode(',', $coord); if(sizeof($coord) < 2) { return 'ERROR'; } $coord[0] = explode(' ', $coord[0]); $coord[1] = explode(' ', $coord[1]); $latt = ($coord[0][1] == 'N') ? $coord[0][0] : '-' . $coord[0][0]; $long = ($coord[1][1] == 'E') ? $coord[1][0] : '-' . $coord[1][0]; return $latt . ',' . $long; That I want to return \\1.\\2 \\3,\\4.\\5 \\6 where the periods output as themselves. Unfortunately, it's not working as I expected. Thank you for your time. Link to comment https://forums.phpfreaks.com/topic/217277-output-period-in-preg_replace/ Share on other sites More sharing options...
.josh Posted October 30, 2010 Share Posted October 30, 2010 TIPS for asking a regex question: - give an example of $coord - give an example of expected match - show what it is giving you instead - be more specific than "it's not working" Link to comment https://forums.phpfreaks.com/topic/217277-output-period-in-preg_replace/#findComment-1128382 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.