我使用$you_value[$i] = str_replace('$', '', $you_value[$i]);
,但它不起作用
我想从阀门获取此链接的值 https://steamcommunity.com/market/priceoverview/?appid=570¤cy=1&market_hash_name=Dragonclaw%20Hook
这是我的代码
$you_value[$i] = "https://steamcommunity.com/market/priceoverview/?appid=570¤cy=1&market_hash_name=".$you_value[$i]."";
$you_value[$i] = str_replace('$', '', $you_value[$i]);
$you_value[$i] = str_replace(' ', '%20', $you_value[$i]);
$you_value[$i] = file_get_contents($you_value[$i]);
$you_value[$i] = json_decode($you_value[$i], true);
$you_success[$i] = $you_value[$i]['success'];
$you_value[$i] = $you_value[$i]['lowest_price'];
我的代码之前正在工作,但我现在不知道它为什么不起作用
答案 0 :(得分:2)
首先获取文件内容
int trollFuncyB(int); // declaration of the function (may be done outside of the function)
trollFuncyB(x); // The call
然后制作一个对象,解码json
$json = file_get_contents('https://steamcommunity.com/market/priceoverview/?appid=570¤cy=1&market_hash_name=Dragonclaw%20Hook');
然后重新兑现美元符号
$obj = json_decode($json);
结果:
$item_without_dollar_sign = str_replace("$", '', $obj->lowest_price);