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 response with status code

header('Content-type: application/json');
http_response_code(200);
echo json_encode([
	'message' => 'thanks'
]);
Comment

php return json

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

php read json request body

//e.g your JSON Req is like this {"UserName":"Ranish","Password":"asdasdasd"}
$jsonReqUrl  = "php://input";
$reqjson = file_get_contents($jsonReqUrl);
$reqjsonDecode = json_decode($reqjson, true);
echo $reqjsonDecode['UserName'];
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

how to receive json data in php

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

how to make a json request in php

<?php
$jsonurl = "http://api.wipmania.com/json";
$json = file_get_contents($jsonurl);
var_dump(json_decode($json));
?>
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

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 :: PHP Function to create GUID 
Php :: if i am using $_SERVER it shows 500 error 
Php :: how to make-migrations in laravel 
Php :: change minutes in to hours carbon 
Php :: Laravel retrieving single record 
Php :: enable gd php 
Php :: php absolute value 
Php :: laravel collection keys 
Php :: laravel deleted controller still cached 
Php :: search function using php for database entries 
Php :: wordpress get post type 
Php :: php color generator 
Php :: how to install php dependencies 
Php :: php if mobile 
Php :: laravel date format 
Php :: php upload file 
Php :: string convert snake case to title case in laravel 
Php :: PDOException::("could not find driver") windows 
Php :: how to share a helper globally laravel 
Php :: How to check if email exists in laravel validaton 
Php :: hiding the extension of website 
Php :: install laravel in bootstrap 8 
Php :: PHP print — Output a string 
Php :: Unable to create PsySH runtime directory. Make sure PHP is able to write to /run/user in order to continue. 
Php :: php random characters 
Php :: invalid datetime format laravel 
Php :: ternary operator for three conditions in php 
Php :: laravel project create with version 
Php :: laravel fortify 
Php :: php round to the nearest 10 
ADD CONTENT
Topic
Content
Source link
Name
9+9 =