Search
 
SCRIPT & CODE EXAMPLE
 

PHP

php return json data

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

$colors = array("red","blue","green");
echo json_encode($colors);
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

json to php array

<?php
        $json = '[{"name":"xxx","phone":"123","email":"a@a.com"},{"name":"yyy","phone":"456","email":"b@a.com"},{"name":"zzz","phone":"678","email":"c@a.com"}]';
        $json_decoded = json_decode($json);
        echo '<table>';
        foreach($json_decoded as $result){
          echo '<tr>';
            echo '<td>'.$result->name.'</td>';
            echo '<td>'.$result->phone.'</td>';
            echo '<td>'.$result->email.'</td>';
          echo '</tr>';
        }
        echo '</table>';
      ?>
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

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

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 :: include in php 
Php :: php proper function comments 
Php :: removing index.php in codeigniter 
Php :: db transaction laravel 
Php :: Eloquent where date methods 
Php :: how to return chunk data laravel 
Php :: convert_uudecode (PHP 5, PHP 7, PHP 8) convert_uudecode — Decode a uuencoded string 
Php :: cakephp 4 change layout view in a method 
Php :: set posts_per_page 
Php :: POP UP WITH PHP 
Php :: Stored Procedures in Laravel 
Php :: set custome table laravel eloquent 
Php :: php clean user input 
Php :: __invoke in laravel 
Php :: How to Connect MySQL Database with PHP Websites 
Php :: laravel migrations generator laravel 
Php :: laravel DB wherein 
Php :: if request type is post 
Php :: php merge array with same value 
Php :: add two numbers in php 
Php :: Root composer.json requires php ^7.1.3 but your php version (8.0.3) does not satisfy that requirement. 
Php :: rawbetween in laravel 
Php :: return view inside subfolder laravel 
Php :: luhn algorithm credit card checker php 
Php :: php strom key 1 
Php :: message get with return action laravel 
Php :: laravel faker select between options 
Php :: change default user table name laravel 
Php :: laravel logs 
Php :: woocommerce return to shop custom url 
ADD CONTENT
Topic
Content
Source link
Name
5+8 =