I have this code:
我有这个代码:
foreach($specs as $spec) {
if(preg_match('/^(\w+):\s*(.*?)\s$?(\d*\.?\d*)$/', $spec, $matches)) {
list(,$tag,$name,$price) = $matches;
$url = 'https://www.googleapis.com/shopping/search/v1/public/products?country=AU&key=KEY&q=' . urlencode($name);
$obj = json_decode(file_get_contents($url));
echo "<a href=\"{$obj->items[0]->product->link}\">{$name}</a> ${$obj->items[0]->product->inventories[0]->price}<br/>";
}
}
foreach($specs as