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. Quote 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" Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.