Search
 
SCRIPT & CODE EXAMPLE
 

PHP

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

how to receive json data in php

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

return json in php

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

PHP code to read JSON string on server

$str_json = file_get_contents('php://input');
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

PREVIOUS NEXT
Code Example
Php :: php for loop 
Php :: acf gallery 
Php :: how to loop array in laravel 
Php :: php get query string 
Php :: how refresh object in database in laravel 
Php :: check if the form is submitted php 
Php :: laravel 8 date format 
Php :: saveAll get all id save cakephp 
Php :: how to create a logfile in php? 
Php :: laravel make seeder 
Php :: string to int php 
Php :: explode in laravel blade 
Php :: artisan commands in route 
Php :: php slugify 
Php :: php multidimensional array get all values by key 
Php :: laravel api enable cors 
Php :: Allowed memory size of 1610612736 bytes exhausted laravel 
Php :: delete_user hook in wordpress 
Php :: show created_at as normal date laravel blade 
Php :: br php 
Php :: return response not found laravel api response 
Php :: laravel run seeder enter timestamps 
Php :: laravel database select 
Php :: pass parameter to view laravel 
Php :: how to get data from html form in php 
Php :: laravel count group by date 
Php :: In PackageManifest.php line 122: 
Php :: how to change date formate in laravel 
Php :: parameterized function in php 
Php :: load database in codeigniter 
ADD CONTENT
Topic
Content
Source link
Name
6+5 =