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

Example: JsonObject.NewArrayOf method

See more JSON Examples

Demonstrates the NewArrayOf method.

Chilkat PHP Extension Downloads

PHP Extension
<?php

include("chilkat.php");

$success = false;

$big_cats = '[\'lion\',\'tiger\',\'leopard\',\'jaguar\',\'cheetah\',\'snow leopard\',\'clouded leopard\',\'cougar\',\'puma\',\'panther\']';

$json = new CkJsonObject();

$json->UpdateString('test','abc');

$success = $json->NewArrayOf('big_cats',$big_cats);
if ($success == false) {
    print $json->lastErrorText() . "\n";
    exit;
}

$json->put_EmitCompact(false);
print $json->emit() . "\n";

//  Result:

//  {
//    "test": "abc",
//    "big_cats": [
//      "lion",
//      "tiger",
//      "leopard",
//      "jaguar",
//      "cheetah",
//      "snow leopard",
//      "clouded leopard",
//      "cougar",
//      "puma",
//      "panther"
//    ]
//  }

?>