English 中文(简体)
折旧[复制]
原标题:Split() deprecated [duplicate]
  • 时间:2012-05-10 23:12:48
  •  标签:
  • php
This question already has answers here:
Closed 11 years ago.

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?

谢谢。

EDIT:

何时使用

$coordinatesSplit = preg_split(",", $coordinates);

我收到以下错误:

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

最佳回答

你们可以采用更简单的措辞:

list($lat,$lng) = explode(",",$coordinates);

这直接将<代码>explode的结果分配给你的两个变量。

问题回答

如评论意见所述,使用explode(。 相反:

$coordinatesSplit = explode(",", $coordinates);




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签