Jump to content

RegEx Help


Satanas

Recommended Posts

Hello PHP Freaks!  ;)

 

I need a little help...

I have a page with Latitude and Longitude coordinates and they are separeted with a blank space.

How can I read them with a RegEx ? I put in bold what I want to get...

 

Here is the format of the line:

LPPT 0 0 N38°46'27.00" W009°08'03.00" LISBOA

 

Tks!

Link to comment
https://forums.phpfreaks.com/topic/117964-regex-help/
Share on other sites

try this

<?PHP
$str = 'LPPT 0 0 N38°46'27.00" W009°08'03.00" LISBOA';
preg_match_all('/\s([^\s]*?")/si', $str, $result, PREG_PATTERN_ORDER);
$result = $result[1];
$Latitude = $result[0];
$Longitude = $result[1];
echo "Latitude = $Latitude <BR>Longitude = $Longitude";
?>

 

*untested*

Link to comment
https://forums.phpfreaks.com/topic/117964-regex-help/#findComment-606852
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.