php - Get information from JSON -
so doing this..
function get_info($data) { $json = file_get_contents("http://site.com/".$data.".json"); $output = json_decode($json, true); return $output; }
which fine , returns this:
array(1) { ["allocation"]=> array(20) { ["carrier_ocn"]=> string(4) "6664" ["available_on"]=> null ["status"]=> string(9) "allocated" ["access_type"]=> string(8) "wireless" ["ratecenter"]=> string(9) "charlotte" ["lat"]=> float(35.2270869) ["contaminations"]=> null ["city"]=> string(9) "charlotte" ["lng"]=> float(-80.8431267) ["current_on"]=> string(10) "2010-04-28" ["block_code"]=> null ["npa"]=> int(704) ["geo_precision"]=> int(4) ["nxx"]=> int(291) ["assigned_on"]=> null ["country"]=> string(2) "us" ["region"]=> string(2) "nc" ["ratecenter_formatted"]=> string(9) "charlotte" ["carrier"]=> string(20) "sprint spectrum l.p." ["effective_on"]=> null } }
how can make return selected values "ratecenter_formatted". want "charlotte" above dump. how this?
thank in advance!
hmmm, fish out array? json_decode()
on json array give php array can use other array in php (in case associative one).
$output = get_info($data); echo $output['allocation']['ratecenter_formatted'];
Comments
Post a Comment