- json_encode: documentation ( source)
<?php
$assoc = [
'Stops' => [
['order_number' => 123, 'whatever' => 'meh'],
['order_number' => 124, 'whatever' => 'meh again'],
]
];
$object = new class() {
public $Stops = [];
public function __construct() {
$this->Stops []= new class() {
public $order_number = 123;
public $whatever = 'meh';
};
$this->Stops []= new class() {
public $order_number = 124;
public $whatever = 'meh again';
};
}
};
echo json_encode($assoc);
echo "\n";
echo json_encode($object);