I have a form with which I collect the data in an array.
$dato1 = $_REQUEST['nombre'];
$dato2 = $_REQUEST['director'];
$dato3 = $_REQUEST['año'];
$dato4 = $_REQUEST['genero'];
$dato5 = $_REQUEST['duracion'];
$alumno = array("nombre" => "$dato1","director" => "$dato2","año" => "$dato3","genero" => "$dato4","duracion" => "$dato5");
$_SESSION['lista'][] = $alumno;
And then I have another form to indicate how I want to order, and a function for each field.
The function that orders me alphabetically, but I want to add ascending or descending order.
function comparatitulo ($x, $y) {
if ($x['nombre'] == $y['nombre']){
return 0;
}elseif ($x['nombre'] < $y['nombre']){
return -1;
}else{
return 1;
}
}
uasort ($_SESSION['lista'], 'comparatitulo');
break;
Can someone help me?
Thanks in advance.