How to determine if a PHP string ONLY contains latitude and longitude
I have to work with strings which may contain Lat/Long data, like this: $query = "-33.805789,151.002060"; $query = "-33.805789, 151.002060"; $query = "OVER HERE: -33.805789,151.002060"; For my purposes, the first 2 strings are correct, but the last one isn't. I am trying to figure out a match pattern which would match a lat and long separated by a comma, or a comma and a space. But if it has anything in the string other than numbers, spaces, dots, minus signs and commas, then it should fail the match. Hope this makes sense, and TIA! ^[+-]?\d+\.\d+, ?[+-]?\d+\.\d+$ The ^ at the start and $ at