# Re: What is the easy way to read and write GPS data?

```I've used example called pel_add_gpsinfo.php. I found it when I followed by
one of links that you gave me.```
```
There is piece of code from this example, including function:

--------------------
\$GPS_LONGITUDE = convertGps(\$GPS_LONGITUDE); //converting from decimal
to conventional coordinate system
\$GPS_LATITUDE = convertGps(\$GPS_LATITUDE);

function convertGps(\$gpsnumber)
{
if (\$gpsnumber > 180 || \$gpsnumber < -180){
echo("Error: Degrees should be between -180 and 180.
(\$gpsnumber)<br>");
return null;
}
else {
\$gpsnumber= abs(\$gpsnumber); //make sure number is positive (no
distinction here for N/S or W/E)
\$gps_array = explode (".", \$gpsnumber); //cut out the first digits
\$deg = \$gps_array[0];    //first digits are degrees
\$min = \$gps_array[1]*60;    //    the remaining digits times 60 are
minutes
\$sec = substr(\$min, 2); //here we take all but the fist 2 digits
\$sec = \$sec * 60; //those times 60 are the secondes
\$sec = substr(\$sec, 0, 3);        //seconds, max length=3
\$min = substr(\$min,0,2); //minutes max length = 2
\$returnarray = array(\$deg,\$min,\$sec);
//echo "Result: \$deg / \$min / \$sec"."<br>";
return \$returnarray;
}
}
--------------------

I wonder where is the error in this function?
```
```-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
```_______________________________________________