PHP возвращает JSON
header('Content-type: application/json');
echo json_encode($array);
Mobile Star
header('Content-type: application/json');
echo json_encode($array);
<?php
$jsonurl = "https://reqres.in/api/users/2";
$json = file_get_contents($jsonurl);
$jsonDecode = json_decode($json, true);
echo $jsonDecode['data']['email'];
?>
header('Content-Type: application/json');
$colors = array("red","blue","green");
echo json_encode($colors);
$data = json_decode(file_get_contents('php://input'), true);
print_r($data);
echo $data;
<?php
$data = '{
"name": "Aragorn",
"race": "Human"
}';
$character = json_decode($data);
echo $character->name;
//code igniter
$query="qry";
$query = $this->db->query($query);
$res=$query->result();
return json_encode($res);