preg-match-使用php从url中获取特定的行


preg match - Get a specific line from a url using php

嗨,我想从给定的url中获取一个特定的行。。。例如,从这个网址,我想得到行"英镑":0.632956。我想我必须使用preg函数,但谁能给我一个如何获得它的例子吗?

谢谢。

这是一个JSON响应,因此不需要任何正则表达式:

$response = file_get_contents('http://openexchangerates.org/api/latest.json?app_id=ae2f63619e8d4cc4bd0beaf9fd73839e');
$data = json_decode($response);
echo $data->rates->GBP;

演示

另请参阅:json_decode()