English 中文(简体)
减少甄选的利差价值分为两个变量? (PHP/RUS)
原标题:Splitting value of drop down selection into two variables? (PHP/HTML)

因此,我上了一个网站,有两张超文本的下游名单——一个是美国国家名单,另一个是选定国家的城市/城市名单。 至现在为止,我每个州都有一个超文本文件,它们都有这样的选择:

<option value="44.729932, -72.381758">Albany</option>
<option value="44.976728, -73.30257">Alburg</option>

The values are the coordinates (latitude, longitude) of each town. When I hit "search", the form data is sent to a PHP script for SimpleGeo (a location database company- amazing, btw)- the purpose of selecting the town is to provide values for $lat and $lon in this part of the PHP script, which is sent to SimpleGeo for every query:

$q = $_GET[ q ];
$lat = 44.729932;
$lon = -72.381758;

$args = array( q  => $q,  num  => 25,  category  => Restaurant,  radius  => 25);
$results = $client->getPlaces($lat, $lon, $args);

The part that can t change is the "getPlaces($lat, $lon, $args);" part because for some reason when I replace $lat and $lon with $coordinates and then replace their values with:

$coordinates = $_GET[ city ]; ( city is the name and id of my city/town lists)

它不认为它是一个有效的问题。 同时,如果你用坐标数字取代“美元、元”的话,它完全理解。

...... 我只需要把我的价值分成几个部分,无论是在超文本档案中,还是通过承认“,意思是纬度值已经结束,而变化价值已经开始。 我不知道应如何做到这一点,我只知道lat和lon必须等于我的超文本档案——每个州一个档案——确定的价值,每个档案平均有500个选择。 我怎么认识到“44.729932、-72.381758”等东西是lat和lon! 或者说,如果我提出这样的选择,那么我如何把我的下级名单放在排位和排位的数值上:

<option lat="44.976728" lon="-73.30257">Alburg</option>

感谢阅读,对它 so了这么长时间! 我的目光是: 帮助

最佳回答

你可以把选择的价值分开,以获得自由度和长度。

-? [0-9]+等格外法确定你的领域, - ?

list($lat, $lon) = explode(", ", $_GET[ city ]);

Here the separator is , including the space, to remove it btw.

问题回答

你可以尝试这样做。

if (isset($_GET[ location ]) AND strpos($_GET[ location ],  ,  ) !== FALSE) {
   list($latitude, $longitude) = explode( ,  , $_GET[ location ]);
}

......如果有人寄给你像<条码>、第4.3条、第3.1条之规定!

Ideone。


或者,你可以利用这一规章验证其的数值。

if ($location = filter_input(INPUT_GET,  location )) {
   preg_match( /^(?P<latitude>-?d+.d+), (?P<longitude>-?d+.d+)z/ , $location, $matches);

   $latitude = $matches[ latitude ];
   $longitude = $matches[ longitude ];
}

Ideone。

以上额外数据的问题或是双方都胜诉。

d 我建议,你使用独一无二的身份证作为价值属性,然后根据用户选择的国际发展法,将选定城市的纬度和经度从你的数据库中排出。

如果你坚持这样做,那么你就能够利用探索方法来分割返还的价值。





相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!