Possible Duplicate:
PHP split alternative?
// Successful geocode
$geocode_pending = false;
$coordinates = $xml->Response->Placemark->Point->coordinates;
$coordinatesSplit = split(",", $coordinates);
// Format: Longitude, Latitude, Altitude
$lat = $coordinatesSplit[1];
$lng = $coordinatesSplit[0];
Hello People, this is a part of my geolocation code. I try to change a stored adress into a lat/long and than save the lat/long back in the database. They use the split function to put a string in an array but since php 5.3.0 the function is deprecated. Anyone has a solution for this?
Thank you
EDIT:
When i use this
$coordinatesSplit = preg_split(",", $coordinates);
I receive following error
preg_split() [function.preg-split]: No ending delimiter
LAST edit When i add something to the database, the long/late are automatically saved to. But when i want to add for example the 6th adress in the database, the script to generate the lat/long is automatically doing this over all the records in the database. Is there any posibility to do this only at the last added? ----> Geolocation LONG/LAN in database
You can get simpler code with:
list($lat,$lng) = explode(",",$coordinates);
This directly assigns the result of explode
into the two variables for you.
As discussed in the comments, use explode()
instead:
$coordinatesSplit = explode(",", $coordinates);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With