“json ke array php” Kode Jawaban

PHP Echo Json

<?php
$data = ['name' => 'John', 'age' => 35];
header('Content-type: Application/json');
echo json_encode($data);
ArtesanoMultimedia

PHP Convert Array ke JSON Object

$myArr = array("apple", "banana", "mango", "jackfruit");

$toJSON = json_encode($myArr);

echo $toJSON;
Lazy Loris

php json_decode

$personJSON = '{"name":"Johny Carson","title":"CTO"}';

$person = json_decode($personJSON);

echo $person->name; // Johny Carson
Grepper

json ke array php

//2 ways
  //this is for string from $_REQUEST,$_POST to array
$jsonText = $_REQUEST['myJSON'];
$decodedText = html_entity_decode($jsonText);
$myArray = json_decode($decodedText, true);

//this is for json to array
$assosiative_array = json_decode(json_encode($jsonText),true);
Splendid Salmon

php mendekode objek json

<?php

$json = '{"firstName":"Peter","lastName:":"Silva","age":23}';

$personInfo = json_decode(json);

echo $personInfo->age;

?>
Apollo

file_get_contents php

function url_get_contents ($Url) {
    if (!function_exists('curl_init')){ 
        die('CURL is not installed!');
    }
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $Url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $output = curl_exec($ch);
    curl_close($ch);
    return json_decode($output,JSON_OBJECT_AS_ARRAY);
}
MrBeanDev

Jawaban yang mirip dengan “json ke array php”

Pertanyaan yang mirip dengan “json ke array php”

Lebih banyak jawaban terkait untuk “json ke array php” di PHP

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya