I am creating a 2D array, in which the first Value shows the time and the other one shows the Random no. with that value. I am creating multiple arrays at the same load using for loop. but the problem is that the time stamp in all the array values prints the same.
so for every array values in the for loop, the time is same.
Here is my Code:
<?php
header("Content-type: text/json");
$arr = [] ;
for($i=0 ;$i<5;$i++)
{
$time = [] ;
$time[] = date('Y-m-d H:i:s') ;
$random_no = [];
$random_no[] = rand(0,10) ;
$arr[] = array_merge($time,$random_no);
}
echo json_encode($arr);
?>
The output I am getting is somewhat like :
[["2019-09-05 07:42:24",8],["2019-09-05 07:42:24",1],["2019-09-05 07:42:24",1],["2019-09-05 07:42:24",3],["2019-09-05 07:42:24",0]]
Note that Time displays the same in every array Value. I just want the time values to be different in an incrementing order