php
  • html
  • json
  • 2016-05-11 144 views 0 likes 
    0

    的字符串我有這樣的JSON(從蒸汽市場):無法讀取JSON

    {"success":true,"lowest_price":"$5.79","volume":"2,932","median_price":"$5.79"}

    而且我有這樣的代碼:

    $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']; 
    

    但是當我嘗試它,他們給我錯了:

    Notice: Undefined index: lowest_price

    什麼是錯?因爲我有一個相同的方法和完美的作品的其他JSON。

    +0

    是用什麼語言你的代碼?編輯您的問題以添加適當的語言標籤。 – Dijkgraaf

    +0

    @Dijkgraaf對不起,我是新的。所有的代碼都是用PHP編寫的。 –

    +0

    '$ name'的值是什麼? –

    回答

    2

    你應該urlencode您varaiable:

    $urlm = 'http://steamcommunity.com/market/priceoverview/?currency=1&appid=730&market_hash_name='. urlencode($name); 
    
    +0

    謝謝!我不這麼認爲。 –

    相關問題