[Solved] how to convert for loop results in json
In your loop, create a new array occurance each iteration. Then use json_encode() to turn that array into a valid JSON string. $json = []; for ($i = 0; $i < (count($getnodays)); $i++) { $json[] = [‘Category’ => $getctgry[$i], ‘Priority’ => $getpriotity[$i], ‘NoOfDays’ => $getnodays[$i], ‘StDate’ => $date1[$i], ‘EdDate’ => $date2[$i], ]; } echo json_encode($json); … Read more