“PHP Access JSON Object” Kode Jawaban

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
?>
SeriousMonk

Akses JSON dengan PHP

<?php

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

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

Mengembalikan JSON dari skrip PHP

<?php
$data = /** whatever you're serializing **/;
header('Content-Type: application/json; charset=utf-8');
echo json_encode($data);
Long Locust

Jawaban yang mirip dengan “PHP Access JSON Object”

Pertanyaan yang mirip dengan “PHP Access JSON Object”

Lebih banyak jawaban terkait untuk “PHP Access JSON Object” di PHP

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya