Encode a kiosk row. Decode back.
Goal
Round-trip a kiosk array.
<?php
$row = ["city" => "Nairobi", "units" => 12];
$text = json_encode($row);
echo $text, PHP_EOL;
echo json_decode($text, true)["units"], PHP_EOL;<?php
$rows = [["city" => "Mombasa", "units" => 8], ["city" => "Kisumu", "units" => 5]];
echo json_encode($rows), PHP_EOL;<?php
$text = '{"city":"Nakuru","units":4}';
echo json_decode($text, true)["city"], PHP_EOL;<?php
$bad = json_decode("not json");
echo $bad === null ? "bad json" : "ok", PHP_EOL;