PHP Requires Chilkat v11.0.0+
Chilkat2 PHP
JSON AppendArray2 Example
Demonstrates the AppendArray2 function.Chilkat PHP Downloads
<?php
use Chilkat2\JsonArray;
use Chilkat2\JsonObject;
$json = new JsonObject();
$json->Load('{ "name": "John", "marbles": 100 }');
// Append an empty array named "xyz"
$jarr = new JsonArray();
$json->AppendArray2('xyz', $jarr);
echo $json->Emit(), "\n";
// Expected output is: {"name":"John","marbles":100,"xyz":[]}
// Add elements to the array.
$jarr->AddStringAt(-1, 'hello');
$jarr->AddIntAt(-1, 256);
echo $json->Emit(), "\n";
// Expected output is: {"name":"John","marbles":100,"xyz":["hello",256]}