Search
 
SCRIPT & CODE EXAMPLE
 

PHP

php access json object

<?php
  // JSON string
  $someJSON = '[{"name":"Jonathan Suh","gender":"male"},{"name":"William Philbin","gender":"male"},{"name":"Allison McKinnery","gender":"female"}]';

  // Convert JSON string to Object
  $someObject = json_decode($someJSON);
  echo $someObject[0]->name; // Access Object data
?>
Comment

access json object in php

$character = json_decode($data);
echo $character->name;
Comment

access json with php

<?php

$data = '{
	"name": "Aragorn",
	"race": "Human"
}';

$character = json_decode($data);
echo $character->name;
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 :: drupal 9 enable PHP errors 
Php :: view pdf file in a new tab in php 
Php :: php limit words 
Php :: install php-fpm centos 7 
Php :: Undefined property: CollectiveAnnotationsRoutingAnnotationsResourcePath::$no_prefix 
Php :: add array to another array in laravel collection 
Php :: carbon 2 days ago 
Php :: php carbon convert string to date 
Php :: php number to word 
Php :: redirect to site php 
Php :: to stop XAMPP ubuntu 
Php :: how to get all rows from a table except some rows in laravel 
Php :: Redirect image attachment pages in Wordpress 
Php :: artisan refresh 
Php :: smarty if 
Php :: mac install multiple php versions 
Php :: change font family in echo php 
Php :: laravel collection each 
Php :: insert php variable css 
Php :: wp-admin redirecting to the https wordpress 
Php :: convert dd/mm/yyyy to yyyy-mm-dd in mysql php 
Php :: laravel get full url with parameters 
Php :: Remove all attributes from HTML tags in PHP 
Php :: php get index of current item array_reduce 
Php :: upload file laravel 
Php :: unset session in php 
Php :: mac os change the php verison 
Php :: smtp server xampp 
Php :: laravel eloquent get last 
Php :: get random data laravel 
ADD CONTENT
Topic
Content
Source link
Name
4+2 =