function listarDatosalumno($rut) { $class_alumno = new alumno(); $alumno = $class_alumno->obtenerAlumno($rut); if ($alumno['estado_matricula'] == '1') { $estado_matricula = "Matriculado"; } else { $estado_matricula = "No Matriculado"; } print json_encode_esp($alumno); }
function json_encode_esp($arr) { $json_str = ""; if (is_array($arr)) { $pure_array = true; $array_length = count($arr); for ($i = 0; $i < $array_length; $i++) { if (!isset($arr[$i])) { $pure_array = false; break; } } if ($pure_array) { $json_str = "["; $temp = array(); for ($i = 0; $i < $array_length; $i++) { $temp[] = sprintf("%s", json_encode_esp($arr[$i])); } $json_str .= implode(",", $temp); $json_str .= "]"; } else { $json_str = "{"; $temp = array(); foreach ($arr as $key => $value) { $temp[] = sprintf("\"%s\":%s", $key, json_encode_esp($value)); } $json_str .= implode(",", $temp); $json_str .= "}"; } } else { if (is_string($arr)) { $json_str = "\"" . encoding($arr) . "\""; } else { if (is_numeric($arr)) { $json_str = $arr; } else { $json_str = "\"" . encoding($arr) . "\""; } } } return $json_str; }