public function autocompletecovenantAction() { $term = $this->_request->getParam('term'); $covenantModel = new CovenantModel(); $covenantData = $covenantModel->fetchAll($covenantModel->getCovenant($term)); $json = '['; $first = true; foreach ($covenantData as $row) { if (!$first) { $json .= ','; } else { $first = false; } $json .= json_encode(array("id" => $row['cdcovenant'], "value" => $row['nmcovenant'])); } $json .= ']'; echo $json; }