I am having trouble with a preg_match_all on a string that contains a degree symbol. The sample of code is below.
//Sample data
$x = "<array_0>
<id>text-21650</id>
<text>Lat/Long 38° 57' 34 N, 106° 21' 38 W</text>
</array_0>";
$reels = '/<(\w+)\s*([^\/>]*)\s*(?:\/>|>(.*)<\/\s*\\1\s*>)/s';
preg_match_all($reels, $x, $elements);
foreach ($elements[1] as $ie => $xx) {
$name = $elements[1][$ie];
$cdend = strpos($elements[3][$ie], "<");
if ($cdend > 0) {
$xmlary[$name] = substr($elements[3][$ie], 0, $cdend - 1);
}
if (preg_match($reels, $elements[3][$ie]))
$xmlary[$name] = processEl($elements[3][$ie]);
else if ($elements[3][$ie] !== null) {
$xmlary[$name] = $elements[3][$ie];
}
}
For some reason it doesn't work properly with the degree symbols in there. If I take it out it works. I would really like to find a way that they can stay in there without changing them. I am also wondering if there may be other extended character that could cause a problem too.
Any help would be greatly appreciated. Thanks