help a PHP hack

Discussion in 'Programming & Software Development' started by mrturkey, Feb 13, 2018.

Tags:
  1. mrturkey

    mrturkey Member

    Joined:
    Jun 27, 2001
    Messages:
    459
    Location:
    Wodonga, VIC
    I am trying to retrieve some json data from a url based on data in a table. My table has the URL to fetch, the name of the value I want to retrieve.

    Code:
    $data = json_decode(file_get_contents('$row->url'));
    echo $data->$row['valuekey'];  // This isn't quite right...
    What is the correct way to reference what I am trying to do?

    Thanks
     
  2. OP
    OP
    mrturkey

    mrturkey Member

    Joined:
    Jun 27, 2001
    Messages:
    459
    Location:
    Wodonga, VIC
    Solved, multiple errors in above.
    Code:
    $cryptodata = json_decode(file_get_contents($row['url']));
    $myvaluekey = $row['lastvaluekey'];
    echo $cryptodata->$myvaluekey;
     
    blued likes this.

Share This Page