PHP Requires Chilkat v11.4.0+
Chilkat2 PHP
Example: JsonObject.NewArrayOf method
See more JSON Examples
Demonstrates theNewArrayOf method.
Chilkat PHP Downloads
<?php
use Chilkat2\JsonObject;
$big_cats = '["lion","tiger","leopard","jaguar","cheetah","snow leopard","clouded leopard","cougar","puma","panther"]';
$json = new JsonObject();
$json->UpdateString('test', 'abc');
try {
$json->NewArrayOf('big_cats', $big_cats);
} catch (\Chilkat2\Exception $e) {
echo $e->getMessage(), "\n";
exit;
}
$json->EmitCompact = false;
echo $json->Emit(), "\n";
// Result:
// {
// "test": "abc",
// "big_cats": [
// "lion",
// "tiger",
// "leopard",
// "jaguar",
// "cheetah",
// "snow leopard",
// "clouded leopard",
// "cougar",
// "puma",
// "panther"
// ]
// }