Skip to content

Instantly share code, notes, and snippets.

@l3ikrant
Forked from anonymous/coordinateValidator.php
Created June 28, 2017 15:30
Show Gist options
  • Select an option

  • Save l3ikrant/996674d8998e43adcadf755e41c89fb9 to your computer and use it in GitHub Desktop.

Select an option

Save l3ikrant/996674d8998e43adcadf755e41c89fb9 to your computer and use it in GitHub Desktop.
Validate geo coordinate
/**
* Checks given coordinate for errors
* @param float $coordinate coordinate
*
* @return bool result
*/
public function checkCoordinate($coordinate) {
if(preg_match('/^[-]?(([0-8]?[0-9])\.(\d+))|(90(\.0+)?);[-]?((((1[0-7][0-9])|([0-9]?[0-9]))\.(\d+))|180(\.0+)?)$/', $coordinate)) {
return true;
}
else {
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment