public function getSupervisorListAsJson() { $jsonArray = array(); $employeeService = new EmployeeService(); $employeeService->setEmployeeDao(new EmployeeDao()); $employeeList = $employeeService->getSupervisorList(); foreach ($employeeList as $employee) { $name = $employee->getFirstName() . " " . $employee->getMiddleName(); $name = trim(trim($name) . " " . $employee->getLastName()); $jsonArray[] = array('name' => $name, 'id' => $employee->getEmpNumber()); } $jsonString = json_encode($jsonArray); return $jsonString; }