Search
 
SCRIPT & CODE EXAMPLE
 

PHP

get json kay value php

$arr = json_decode($json, true);
 
// Loop through the associative array
foreach($arr as $key=>$value){
    echo $key . " => " . $value . "<br>";
}
Comment

php return json

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

php json request get value

<?php
$jsonurl = "https://reqres.in/api/users/2";
$json = file_get_contents($jsonurl);
$jsonDecode = json_decode($json, true);
echo $jsonDecode['data']['email'];
?>
Comment

read-json-data-response-using-php

$json_data = '{
      "stat": "ok",
      "profile": {
        "providerName": "testing",
        "identifier": "http://testing.com/58263223",
        "displayName": "testing",
        "preferredUsername": "testing",
        "name": {
          "formatted": "testing"
        },
        "url": "http://testing.com/testing/",
        "photo": "https://securecdn.testing.com/uploads/users/5826/3223/avatar32.jpg?1373393837",
        "providerSpecifier": "testing"
      }
    }';

$json = json_decode($json_data);

echo $json->profile->displayName;
echo $json->profile->preferredUsername;
Comment

php return json data

header('Content-Type: application/json'); 

$colors = array("red","blue","green");
echo json_encode($colors);
Comment

php return a json response

//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 },
Comment

access json object in php

$character = json_decode($data);
echo $character->name;
Comment

how to receive json data in php

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

how to get data from json array in php

 $data = json_decode($json);
Comment

json php

<?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);
   }
Comment

access json with php

<?php

$data = '{
	"name": "Aragorn",
	"race": "Human"
}';

$character = json_decode($data);
echo $character->name;
Comment

return json in php

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

how to extract data from json in php

$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);
Comment

read-json-data-response-using-php

$json = '[
    {
        "displayName": "testing",
        "preferredUsername": "testing",
    }
]';

$jsonArray = json_decode($json);

foreach($jsonArray as $value){
    $displayName = $value->Display Name;
    $preferredUsername = $value->Preferred User;
}
Comment

php object to json

function getJsonData(){
    $var = get_object_vars($this);
    foreach ($var as &$value) {
        if (is_object($value) && method_exists($value,'getJsonData')) {
            $value = $value->getJsonData();
        }
    }
    return $var;
}
Comment

Returning JSON from a PHP Script

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

PREVIOUS NEXT
Code Example
Php :: array_chunk in php 
Php :: python to php converter online 
Php :: if home else php wordpress 
Php :: laravel pluck 
Php :: php <= 
Php :: laravel uuid not showing in query 
Php :: Laravel - Resize image size using Laravel image class 
Php :: Laravel - Send mail using mail class 
Php :: wordpress query get results 
Php :: php webserver 
Php :: drop foreign key laravel eloquent 
Php :: orderby total sales woocommerce 
Php :: laravel file uploads 
Php :: composer create project laravel with version 
Php :: file is empty in php 
Php :: Laravel Migrations from an existing database 
Php :: carbon this month first day 
Php :: change or set post type wordpress 
Php :: php api 
Php :: disadvantages of php 
Php :: laravel migration table softdeletes 
Php :: variables in php 
Php :: laravel one command for model table and controller 
Php :: js php number format space 
Php :: php thread safe or non thread safe 
Php :: php max 
Php :: php convert float 
Php :: storefront remove sidebar from product page 
Php :: php file date created older than 
Php :: laravel digits between does not working 
ADD CONTENT
Topic
Content
Source link
Name
9+6 =