“JSON an Array PHP” Code-Antworten

PHP Echo Json

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

PHP konvertieren Array in JSON -Objekt

$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 an 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 -Dekodus JSON -Objekt

<?php

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

$personInfo = json_decode(json);

echo $personInfo->age;

?>
Apollo

Datei_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

Ähnliche Antworten wie “JSON an Array PHP”

Fragen ähnlich wie “JSON an Array PHP”

Weitere verwandte Antworten zu “JSON an Array PHP” auf PHP

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen