Reputation: 457
How do I stop the browser adding amp; on every & there is in the URL?
So I am trying to get a JSON file from a URL
However, it keeps on adding amp; on every & there is, which makes the JSON returns null.
URL becomes: (http://steamcommunity.com/market/priceoverview/?currency=1&appid=570&market_hash_name=Inscribed%20Blades%20of%20Voth%20Domosh
Can anyone help me to stop my php doing this all the time?
Here is my code:
$priceURL = 'http://steamcommunity.com/market/priceoverview/?currency=1&appid=570&market_hash_name=Genuine%20Bloodfeather%20Wings ';
$priceString = file_get_contents($priceURL);
$price_json = json_encode($priceString, true);
echo $price_json['lowest_price'];
Upvotes: 1
Views: 2199
Reputation: 34914
You should decode url, use like this.
$priceURL = 'http://steamcommunity.com/market/priceoverview/?currency=1&appid=570&market_hash_name=Genuine%20Bloodfeather%20Wings ';
$priceURL = urldecode($priceURL);
Upvotes: 0