prepare($sql); $sth->execute([ ":company_id" => $company_id ]); db_check($sth, $answer); $answer["output"] = $sth->fetchAll(PDO::FETCH_ASSOC); // modify output foreach($answer["output"] as $key => $item){ // status if($item["status"]==1){ $answer["output"][$key]["status"] = 'Active'; $answer["output"][$key]["bg_class"] = 'success'; }else{ $answer["output"][$key]["status"] = 'Inactive'; $answer["output"][$key]["bg_class"] = 'secondary'; } } $answer["success"] = 1; exit(json_encode($answer)); ?>