Skip to content

Instantly share code, notes, and snippets.

@NiltonMorais
Created October 3, 2017 16:54
Show Gist options
  • Select an option

  • Save NiltonMorais/b95899ed7a6843c258d13587e1ac5192 to your computer and use it in GitHub Desktop.

Select an option

Save NiltonMorais/b95899ed7a6843c258d13587e1ac5192 to your computer and use it in GitHub Desktop.
<?php
$strBD = "POLYGON((-22.886145457836463 -43.118764097835, -22.88643210096987 -43.118324215556555, -22.886694032959 -43.117846782351904, -22.886763222456636 -43.11767512097496, -22.886782990878046 -43.117605383540564, -22.886886775043237 -43.11763757004875, -22.887133879879073 -43.11891966595787, -22.88630360584699 -43.11942392125267, -22.886115805063966 -43.118823106433325, -22.886145457836463 -43.118764097835))";
$newStr = str_replace('POLYGON((','',$strBD);
$newStr = str_replace('))','',$newStr);
$array = explode(',',$newStr);
$newArray = [];
foreach ($array as $item){
$subArray = explode(' ',$item);
$newArray[] = [
'lat' => $subArray[0],
'long' => $subArray[1],
];
}
var_dump($newArray);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment