How To Receive Json Data In Php

[Solved] How To Receive Json Data In Php | Php - Code Explorer | yomemimo.com
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 : 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 : how to make a json request in php

Answered by : derson--alves-da-silva

<?php
$jsonurl = "http://api.wipmania.com/json";
$json = file_get_contents($jsonurl);
var_dump(json_decode($json));
?>

Source : https://stackoverflow.com/questions/9930434/simple-json-request-in-php | Last Update : Sun, 03 May 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 : json php

Answered by : angry-alpaca-fuiv8tz9m00m

<?php
header("Content-Type: application/json; charset=utf-8");
if (!empty($_REQUEST['q'])){ $q = $_REQUEST['q']; require_once('api-key.php'); $apiUrl = "http://api.openweathermap.org/data/2.5/weather?q=" . $q . "&lang=fr&units=metric&APPID=" . API_KEY; $response = file_get_contents($apiUrl, False); $data = json_decode($response, true); // $data = TABLEAU PHP setLocale(LC_TIME,"fr_FR.UTF-8"); date_default_timezone_set("Europe/Paris"); $today = strftime('%A %d %B %y',time()); $hour = date('H:i:s'); // on prépare un tableau $json pour la réponse $json = array("lieu" => $q, "jour" => $today, "heure"=> $hour, "meteo"=> array()); $json['meteo']['main'] = $data['main']; $json['meteo']['description'] = $data['weather'][0]['description']; $json['meteo']['id'] = $data['weather'][0]['id']; echo json_encode($json,JSON_PRETTY_PRINT); }

Source : https://www.univ-orleans.fr/iut-orleans/informatique/intra/tuto/php/php-json.html | Last Update : Thu, 06 Oct 22

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 how to receive json data in php

Code Explorer Popular Question For Php