code = "0"; $return->msg="Sin cursos"; }else{ $return->code = "1"; $return->msg="cursos"; $return->datos = []; while ($row = mysqli_fetch_array ($result)){ $img = trim((string)$row["imagen"]); if ($img !== '' && !preg_match('~^(https?:)?//~i', $img)) { $img = rtrim($CFG->wwwroot, '/') . '/' . ltrim($img, '/'); } $row["imagen"] = $img; $return->datos[] = $row; } } echo json_encode($return, JSON_UNESCAPED_UNICODE); mysqli_free_result($result); exit; ?>