Reputation: 155
I'm trying to match DMS latitude/longitude. I've run into a bit of a snag, though. I can detect the pattern so far, but the match keeps returning a nonsense character next to a special character. Here is my code:
//Begin code
$pattern = '/[0-9]{1,3}[:| |\x{00B0}]{0,1}[0-9]{1,2}[\']{0,1}[0-9]{1,2}["]{0,1}[N|S|E|W]/ui';
$value = "12°30'23\"S";
preg_match($pattern,$value,$matches);
print_r($matches);
//End code
and here is the output:
Array ( [0] => 12°30'23"S )
As you can see, an undesired  exists between the 12 and the °.
Please help!
Upvotes: 0
Views: 130
Reputation: 889
Have you verified the charset is set to UTF-8 or Unicode in the HTTP headers? See this page for more info on PHP and Unicode: http://ibm.com/developerworks/library/os-php-unicode/index.html
Upvotes: 1