title: Convert JSON string to PHP Variable
body: <p>I have a JSON array with Yahoo Weather API data:</p>
  
  <pre><code>"query":{
    "count":1,
    "created":"2015-09-08T15:33:25Z",
    "lang":"en-US",
    "results":{
      "channel":{
        "item":{
          "condition":{
            "code":"30",
            "date":"Tue, 08 Sep 2015 11:13 am EDT",
            "temp":"81",
            "text":"Partly Cloudy"
          }
        }
      }
    }
  }
  </code></pre>
  
  <p>I just need to get <code>temp</code> and <code>text</code> and save them as variables... how do I do this?</p>
  
  <p>I've tried encode, decode, subtr, and a few other methods, but can't seem to get the syntax right.
  I've tried instructions from <a href="https://stackoverflow.com/questions/9170639/convert-json-string-to-php-array">Convert JSON string to PHP Array</a></p>
  
  <p>Here's the code on my site:</p>
  
  <pre><code>  $BASE_URL = "http://query.yahooapis.com/v1/public/yql";
    $yql_query = 'select item.condition from weather.forecast  where woeid in (select woeid from geo.places(1) where text="'.$city.', '.$state.'")';
    $yql_query_url = $BASE_URL . "?q=" . urlencode($yql_query) . "&amp;format=json";
    // Make call with cURL
    $session = curl_init($yql_query_url);
    curl_setopt($session, CURLOPT_RETURNTRANSFER,true);
    $json = curl_exec($session);
    // Convert JSON to PHP object
    $phpObj =  json_decode($json);
  
      echo '&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;';
  
      echo $json;
  </code></pre>