R. Rio R. Rio - 2 years ago 84
PHP Question

Can't read a string of JSON

I have this JSON (is from Steam Market):


And I have this code:

$urlm = 'http://steamcommunity.com/market/priceoverview/?currency=1&appid=730&market_hash_name='.$name;
$market = json_decode(file_get_contents($urlm), true);
echo $market['lowest_price'];

But when I try it, they give me an error:

Notice: Undefined index: lowest_price

What is wrong? Because I have an other JSON with the same method and works perfect.

Answer Source

You should urlencode your varaiable:

$urlm = 'http://steamcommunity.com/market/priceoverview/?currency=1&appid=730&market_hash_name='. urlencode($name);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download