在PHP中获取在线计算
好的,我使用文件内容从一个网站获取输出,现在我基本上是从这个网站获取结果 范例 我该怎么做?我的意思是这是我目前的代码,但正如你所看到的,它基本上显示了整个网站在PHP中获取在线计算,php,Php,好的,我使用文件内容从一个网站获取输出,现在我基本上是从这个网站获取结果 范例 我该怎么做?我的意思是这是我目前的代码,但正如你所看到的,它基本上显示了整个网站 function getDistance($x, $y, $xA, $yA) { $distance_ = file_get_contents("http://boulter.com/gps/distance/?from=".$x."+".$y."&to=".$xA."+".$yA."&units=k"
function getDistance($x, $y, $xA, $yA) {
$distance_ = file_get_contents("http://boulter.com/gps/distance/?from=".$x."+".$y."&to=".$xA."+".$yA."&units=k");
echo $distance_;
}
如果您想获得距离,下面是一个粗略的示例:
$distance = file_get_contents('url');
//match all td elements since the data is tabular
preg_match_all('/<td.*(.*?)<\/td>/si', $distance, $matches);
//remove html tags
$string = strip_tags($matches[0][0]);
$distance = substr($string, -26); //ouput is string(26) "1.36 kilometers E (96°)--"
$distance=文件获取内容(“url”);
//匹配所有td元素,因为数据是表格
preg_match_all('/您希望从该页面中得到什么?距离标题下的值?