$content ]; Database::update('c_quiz_question', $params, ['id = ? and c_id = ?' => [$id, $courseId]]); $sql = "SELECT iid, answer, comment FROM c_quiz_answer WHERE question_id = $id and c_id = $courseId"; $result = Database::query($sql); $items = Database::store_result($result, 'ASSOC'); foreach ($items as $item) { $id = $item['iid']; $content = fixText($item['answer']); $params = [ 'answer' => $content ]; Database::update('c_quiz_answer', $params, ['iid = ? ' => $id]); } } function fixText($content) { $matches = []; if (preg_match_all('/(.*)?/', $content, $matches)) { $count = count($matches[0]); for ($i = 0; $i <= $count; $i++) { if (isset($matches[0]) && isset($matches[0][$i])) { $value = "`".$matches[1][$i]."`"; $content = str_replace($matches[0][$i], $value, $content); } } } return $content; }