The array itself (too large to fit here). It is necessary to display the description (163 line).

Array I get api request

<?php $query = 'select * from weather.forecast where woeid in (select woeid from geo.places(1) where text="nome, ak")'; $api_request = "http://query.yahooapis.com/v1/public/yql?q=" . urlencode($query) . "&format=json"; $result = file_get_contents($api_request); $result_decode = json_decode($result); echo '<pre>' . var_export($result_decode, true) . '</pre>'; 

I understand that you need to use array_keys($result []) , but what to take as a value for the search?

  • 3
    option $result_decode->query->results->channel->item->description not working? - teran
  • Thank! Works! Only quotes remain ideone.com/Dv4J1h (1 and 34 line) ... - Tarasovych
  • one
    you have there quotes are drawn, because through var_export output the variable. This is a string here in quotes. The variable itself does not contain them. You can check and print it via print, echo, etc. - teran
  • one
    I will tell you, except for there ]]> at the end there is also <![CDATA[ at the beginning (: remove replace. - teran
  • one
    <![CDATA[ in the beginning, it is also necessary to remove (look at the output source html-code) - teran

1 answer 1

 <?php $query = 'select * from weather.forecast where woeid in (select woeid from geo.places(1) where text="'.$_POST['city'].', ak")'; $api_request = "http://query.yahooapis.com/v1/public/yql?q=" . urlencode($query) . "&format=json"; $result = file_get_contents($api_request); $result_decode = json_decode($result); $description = $result_decode->query->results->channel->item->description; //получаю нужную часть массива $weather = stristr($description,']]>',true); //убираю ненужные символы в конце echo $weather;