arrays - trying to scrape data of json in php not working -


why won't work should scrape definition pp , won't work :/

<?php $json_output = file_get_contents("http://api.urbandictionary.com/v0/define?term=pp"); $json = json_decode($json_output, true); $chuck_noris = $json['list']['definition']; print_r($chuck_noris ); ?> 

there still dimension inside $json['list'] (its still array). can use foreach values inside it:

$json_output = file_get_contents("http://api.urbandictionary.com/v0/define?term=pp"); $json = json_decode($json_output, true); foreach($json['list'] $list) {     // $list hold each array inside `$json['list']`     echo $list['definition'] . '<br/>'; } 

or explicitly pointing first result:

echo $json['list'][0]['definition']; 

Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -