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 :: php artisan serve stop 
Php :: class name laravel 
Php :: referencing constant in config laravel 
::  
Php :: php get array key like 
Php :: laravel request file empty 
Php :: compare two datetime php 
Php :: how to filter laravel eloquent 
Php :: -sale_price 
Php :: hex2bin (PHP 5 = 5.4.0, PHP 7, PHP 8) hex2bin — Decodes a hexadecimally encoded binary string 
Php :: Write a php program to perform sum of two numbers 
Php :: loginByUserID in conrete 
Php :: convert to string php 
Php ::  
Php :: php convert float 
Php :: php url variable xss sanitize 
Php :: php reload after env 
Php :: jwt return true 
Php :: php file iterator 
Php :: laravel validation if another record is not deleted / not null 
Php ::  
Php :: octobercms mail register 
Php :: php user ip from post request 
Php :: status code 301 
Php :: phpmailer doesnt work 
Php :: php inverse / arc cosine 
Php :: php substr_replace 
Php :: laravel disable logging 
Php :: how to enable auto refresh on save 
Php :: php sum array values by key 
ADD CONTENT
Topic
Content
Source link
Name
6+2 =