json - How to pass php variable inside json_decode function -
see below code : trying pass variable called $search_term inside json_decode function not working. need do?
$search_term = $this->input->post('search'); //echo $search_term; die(); $jsonarray = json_decode(file_get_contents('http://www.bloomapi.com/api/search?limit=10&offset=0&key1=practice_address.zip&op1=eq&value1='.$search_term),true); print_r($jsonarray);
i check it's correct change post method can test quickly. it's working fine work post value also.
$search_term = $this->input->get('search'); $jsonarray = json_decode(file_get_contents('http://www.bloomapi.com/api/search?limit=10&offset=0&key1=practice_address.zip&op1=eq&value1=' . $search_term), true); print_r($jsonarray);
you recheck $search_term = $this->input->post('search'); other wise follow bellow instruction proper debuging
$search_term = $this->input->post('search'); $api_url = 'http://www.bloomapi.com/api/search?limit=10&offset=0&key1=practice_address.zip&op1=eq&value1=' . $search_term; echo $api_url;exit; $jsonarray = json_decode(file_get_contents($api_url), true); print_r($jsonarray);
Comments
Post a Comment