Making two out of one?

I want to enter coordinates easy for a page I am building. The input looks something like this:
57.34728867061955:12.0577787920289

I want to copy and paste that line into a field I have, but when I submit my page, I want that line to be stored in two different fields in my table.
I want the first part to be lifted all the way until the : sign. Then I want the part that is shown after the : to be inserted into another field in my table, so I get the first part in the longitude field and the second part in the latitude field in my table and just get rid of the : that is left.

What is the easiest way to do this? Is there something I can use to check everything before the colon and make that one string and the second one as another string?

I’d use the PHP explode function

<?php
$coordinates="57.34728867061955:12.0577787920289";
$split = explode(":", $coordinates);
echo $split[0]; // latitude
echo "<br>"; //space for you to see
echo $split[1]; // longitude
?>

Untested, but it should work. http://php.net/explode

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.