I want to create a JSON format of an array using PHP, but my result is only the latest data and is being replaced.
How can I show all days?
Code:
for($i=1;$i<5;$i++) {
$ar -> date = date("j F y",strtotime("+".$i." days"));
$ar -> id = $i;
}
echo json_encode($ar);
Current result:
{"date":"8 May 19","id":4}