PHP Extension
PHP Extension
Copy JSON Object from one JSON Array to Another
See more JSON Examples
Demonstrates how to copy an object in a JSON array to another JSON array.Chilkat PHP Extension Downloads
<?php
include("chilkat.php");
$arr1 = new CkJsonArray();
$arr2 = new CkJsonArray();
$s = '[{\'a\':1}, {\'b\':2}, {\'c\':3}]';
$sEmpty = '[]';
$arr1->Load($s);
$arr2->Load($sEmpty);
$jObj = new CkJsonObject();
$arr1->ObjectAt2(1,$jObj);
$arr2->AddObjectCopyAt(-1,$jObj);
print $arr2->emit() . "\n";
// output is: [{"b":2}]
?>