¿Cómo puedo quitar las comillas del id
en un JSON generado con PHP?
Mi código:
$students = array();
while($row = mysqli_fetch_array($result))
{
$id = $row['student_id'];
$student_name = $row['student_name'];
$student_image = $row['student_image'];
$student_course = $row['student_course'];
$students[] = array(
'id'=> $id,
'student_name'=> $student_name,
'student_image'=> $student_image,
'student_course'=> $student_course,
);
}
$close = mysqli_close($connection)
or die("An unexpected error has occurred in the disconnection of the database");
$json_string = '{"students":' . json_encode($students) . '}';
print ($json_string)
Quiero obtener este resultado:
"students": [ { "id": 1, "student_name": "David John", "student_image": "avatar.jpg", "student_course": "10", },