Hi guys I need your help in a php module that I'm building, I just want to print a list of cities in JSON but when I do not print anything, I do not know what may be happening: this is my code:
<?php
require "../model/Ciudad.php";
$_POST = $_GET;
function ListaCiudades(){
$ciudad = new Ciudad();
$ciudades = $ciudad->Select_Ciudaddes();
$array_return = array();
if($ciudades != null){
foreach ($ciudades as $ciudad) {
$arr = array("id_ciudad" => $ciudad['PK_ID_CIUDAD'],
"nombre" => $ciudad['NOMBRE'], );
array_push($array_return, $arr);
}
}
return $array_return;
// var_dump(json_encode($array_return, JSON_FORCE_OBJECT));
}
/*Identificación del típo de consulta a realizar*/
if(isset($_POST['tipo'])){
if($_POST['tipo'] == 'consulta'){
if(isset($_POST['consulta'])){
switch ($_POST['consulta']) {
case 'ciudades':
$listado = ListaCiudades();
echo json_encode($listado); //Aqui es donde no me imprime
break;
}
}
}
}
?>
Thanks for your collaboration