Below is a representation of a Polygon in a KML. See:
<coordinates>
-112.2550785337791,36.07954952145647,20
-112.2549277039738,36.08117083492122,20
-112.2552505069063,36.08260761307279,20
-112.2564540158376,36.08395660588506,20
-112.2580238976449,36.08511401044813,20
-112.2595218489022,36.08584355239394,20
-112.2608216347552,36.08612634548589,20
-112.262073428656,36.08626019085147,20
-112.2633204928495,36.08621519860091,20
-112.2644963846444,36.08627897945274,20
-112.2656969554589,36.08649599090644,20
</coordinates>
The last coordinate value, or 20
, represents the altitude, according to the documentation , which I do not need. So at first I made a foreach
like this below:
foreach($names as $coordinate) {
$coordinates[] = explode( ',20', $coordinate );
}
But if altitude changes in any situation, this rule in explode
will not work. What would be a viable way to solve this problem and catch only those convicted ignoring altitude? Can a regular expression solve this?