Returning Json From A Php Script

[Solved] Returning Json From A Php Script | Php - Code Explorer | yomemimo.com
Question : php return json

Answered by : mobile-star

header('Content-type: application/json');
echo json_encode($array);

Source : | Last Update : Fri, 27 Mar 20

Question : php return json data

Answered by : code-grepper

header('Content-Type: application/json');
$colors = array("red","blue","green");
echo json_encode($colors);

Source : | Last Update : Wed, 06 Nov 19

Question : how to receive json data in php

Answered by : perfect-pigeon

$data = json_decode(file_get_contents('php://input'), true);
print_r($data);
echo $data;

Source : https://stackoverflow.com/questions/18866571/receive-json-post-with-php | Last Update : Sun, 08 Nov 20

Question : php return a json response

Answered by : david-cortesi

//PHP File
<?php
$data = /** whatever your data are **/;
header('Content-Type: application/json; charset=utf-8');
echo json_encode($data);
//In JS File
//JQUERY AJAX $.ajax({ url: "path/to_php_file.php", dataType: "json", type: "GET", data: {datax : datax },

Source : https://stackoverflow.com/questions/4064444/returning-json-from-a-php-script | Last Update : Wed, 02 Feb 22

Question : accessing json data in php

Answered by : borma425

$json = '
{ "type": "donut", "name": "Cake"
}';
$yummy = json_decode($json);
echo $yummy->type; //donut

Source : https://stackoverflow.com/questions/29308898/how-do-i-extract-data-from-json-with-php | Last Update : Tue, 19 Oct 21

Question : access json with php

Answered by : better-bison-7ur2i4n3weko

<?php
$data = '{	"name": "Aragorn",	"race": "Human"
}';
$character = json_decode($data);
echo $character->name;

Source : https://www.taniarascia.com/how-to-use-json-data-with-php-or-javascript/ | Last Update : Thu, 27 Aug 20

Question : return json in php

Answered by : annoyed-armadillo-ik49ahzrg9e2

//code igniter
$query="qry";
$query = $this->db->query($query);
$res=$query->result();
return json_encode($res);

Source : | Last Update : Thu, 01 Oct 20

Question : how to extract data from json in php

Answered by : ankur-prajapati

$json = '
{ "type": "donut", "name": "Cake", "toppings": [ { "id": "5002", "type": "Glazed" }, { "id": "5006", "type": "Chocolate with Sprinkles" }, { "id": "5004", "type": "Maple" } ]
}';
$yummy = json_decode($json);
print_r($yummy);

Source : https://stackoverflow.com/questions/29308898/how-do-i-extract-data-from-json-with-php | Last Update : Tue, 15 Jun 21

Question : Returning JSON from a PHP Script

Answered by : long-locust-6bchlrhsm70y

<?php
$data = /** whatever you're serializing **/;
header('Content-Type: application/json; charset=utf-8');
echo json_encode($data);

Source : https://stackoverflow.com/questions/4064444/returning-json-from-a-php-script | Last Update : Thu, 25 Nov 21

Answers related to returning json from a php script

Code Explorer Popular Question For Php