Codeigniter JSON Curl

Class MY_Loader extends CI_Loader { public $_json_array = array(); public function __construct() { parent::__construct(); $this->ci = &get_instance(); } public function view($view, $vars = array(), $return = FALSE) { $format = $this->ci->input->get('format'); if($format == 'json') { $this->ci->_json_array[$view] = $vars; $this->ci->output ->set_output(json_encode($this->ci->_json_array, JSON_NUMERIC_CHECK)); } else { parent::view($view, $vars, $return); } } }
Learn how to display data in codeigniter JSON using CURL ( https://www.cloudways.com/blog/codeigniter-json-curl/ )

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.