Welcome Guest, Not a member yet? Register   Sign In
How do I replace front-end views with JSONs in Codeigniter 3?
#9

(This post was last modified: 08-22-2019, 01:48 AM by ciadmin.)

Quote:Great. It works as desired. 

How can I make the json pretty, from the controller?


https://www.php.net/manual/en/function.json-encode.php
PHP Code:
public function index() {
   $data['something'] = 'whatever is appropriate';
   $this->output->set_content_type('application/json')->set_output(json_encode($data,JSON_PRETTY_PRINT));

Reply


Messages In This Thread
RE: How do I replace front-end views with JSONs in Codeigniter 3? - by ciadmin - 08-22-2019, 01:47 AM



Theme © iAndrew 2016 - Forum software by © MyBB