json response to array php code example
Example 1: php return json
header('Content-type: application/json');
echo json_encode($array);
Example 2: php json encode
$person = array(
"name" => "Johny Carson",
"title" => "CTO"
);
$personJSON=json_encode($person);//returns JSON string
Example 3: return json in php
//code igniter
$query="qry";
$query = $this->db->query($query);
$res=$query->result();
return json_encode($res);