Skip to content

Instantly share code, notes, and snippets.

Created April 11, 2014 09:43
Show Gist options
  • Select an option

  • Save anonymous/10454111 to your computer and use it in GitHub Desktop.

Select an option

Save anonymous/10454111 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