foreach ($therapies as $th) { if ($third) { $third = false; } else { $json .= ','; } $json .= '{ "id" : ' . $th->get_id() . ', "name" : "' . $th->get_name() . '", "description" : "' . $th->get_description() . '" }'; } $json .= '], "schedule" : ['; $schedule = $c->get_schedule(); $four = true; foreach ($schedule as $sh) { if ($four) { $four = false; } else { $json .= ','; } $json .= '{ "days" : ['; $days = $sh->get_days(); $five = true; foreach ($days as $day) { if ($five) { $five = false; } else {