Last active
June 24, 2019 17:24
-
-
Save filippomangione/6f9d78e955ae2f228d28 to your computer and use it in GitHub Desktop.
A simple function to validate latitude and longitude in php.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function validateGeoCoords($lat=null,$lng=null) { | |
return (trim($lat,'0') == (float)$lat) && (trim($lng,'0') == (float)$lng); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To implement validation for latitude and longitude values we can write a logic that, latitude must be a number between -90 and 90 and the longitude between -180 and 180 degree inclusive. Yo can get the free source code from here