I am saving data in php array in loop and then use json_encode function. Here is my code
foreach ($object_ids as $value) {
$booking_data = array(
'name' => $name,
'phone' => $phone,
'email' => $email,
);
}
$booking_data = json_encode($booking_data,true);
print_r($booking_data);
and then is the result I got
{"name":"Peter ","phone":"03008000000","email":"[email protected]"}{"name":"Jessica ","phone":"03038518000","email":"[email protected]"}{"name":"Anas ","phone":"03234152099","email":"[email protected]"}{"name":"Anas ","phone":"03234152099","email":"[email protected]"}
When I tried to beautify I get this error:
The comma is missing while encoding. Please let me know my mistake.
Regards