[
{
"id": 1000,
"date": "2020-07-22 18:57:51",
"customer": "Hilary Greer",
},
{
"id": 1001,
"date": "2020-04-19 03:39:30",
"customer": "Yen Ortega",
},
{
"id": 1002,
"date": "2019-07-03 15:44:11",
"customer": "Maris Oconnor",
},
........
]
$jsonOrders = file_get_contents('templates/api/index.html.twig');
$orders = json_decode($jsonOrders);
foreach($orders as $order)
{
if($order->id == 1002)
{
$order->customer = 'updated';
}
}
file_put_contents('templates/api/index.html.twig', json_encode($orders)); // Перекодировать в формат и записать в файл.
$jsonOrders = file_get_contents('templates/api/index.html.twig');
$orders = json_decode($jsonOrders); //,TRUE
foreach($orders as $order)
{
if($order->id == 1002)
{
$order->status = 'cancelled';
}
}
file_put_contents('templates/api/index.html.twig', json_encode($orders));