Array to JSON

To display array values in JSON format, you need to use json_encode().

For eg:
$arr = array('username' => 'test','userid' =>'1', 'password' => 'test123');

// Use json_encode to return in json format
echo json_encode($arr);

Output:
{"username":"sham dhar","userid":"36","password":"test123"}

Comments

Popular posts from this blog

Ghostscript Installation and Configuration in Windows 7

Joomla - Get user id