Search
 
SCRIPT & CODE EXAMPLE
 

PHP

php return json

header('Content-type: application/json');
echo json_encode($array);
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 get data from json array in php

 $data = 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

PHP code to read JSON string on server

$str_json = file_get_contents('php://input');
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 :: laravel filter array 
Php :: how change resource route parameters lravel 
Php :: class name laravel 
Php :: check php-fpm version ubuntu 
Php :: Non-static method called statically php 
Php :: drupal 8 entity_view 
Php :: install multiple php versions windows xampp 
Php :: mktime syntax php 
Php :: -regular_price 
Php :: PHP stripcslashes — Un-quote string quoted with addcslashes() 
Php :: laravel migration text length 
Php :: php detect daylight saving time DST 
Php :: this app is not allowed to query for scheme fb-messenger" 
Php :: php get json objects by key without indez 
Php :: How I can generate the unique transaction ID in laravel 8 
Php :: Toaster switch Statement 
Php :: Skip model accessor laravel8 
Php :: hummingbird remove caching specific page php 
Php :: laravel 7 requirements 
Php :: yii2 activeform adding field css class 
Php :: tidak bisa install php7.3 di ubuntu 20.04 
Php :: action php self 
Php :: add class to row laravel 
Php :: laravel allow all fillable 
Php :: find auth laravel 
Php :: laravel create model for existing table 
Php :: Laravel Deploy in production 
Php :: php convert path from server url to link 
Php :: bind param php 
Php :: laravel 8 search with pagination 
ADD CONTENT
Topic
Content
Source link
Name
1+5 =