Sample code for 30+ languages & platforms
PHP Requires Chilkat v11.4.0+

Example: JsonObject.NewArrayOf method

See more JSON Examples

Demonstrates the NewArrayOf method.

Chilkat PHP Downloads

Chilkat2 PHP
<?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"
//   ]
// }