The problem is that I have to enter name, id and age, so after reading the data I have to print it as a "table" from highest to lowest taking into account the age. I know that in php sort, rsort and other functions are used for sorting arrays, but I don't know how to do it when it's an array within another.
The idea is that the array that is in position 1 passes to position 0
What I expect to come out in this case is that the row containing "hello", "5", "87" remains in the place of the row containing "AAA" that is, if the age is greater, then it remains in the first position
<?php
session_start();
if ($_POST) {
if (isset($_POST['enviar'])) {
$_SESSION['personas'][]=["nombre" => $_POST['nombre'],
"cedula" => $_POST['cedula'],
"edad" => $_POST['edad']];
}
if(isset($_POST['eliminar'])){
unset($_SESSION['personas'][$_POST['ind']]);
}
foreach($_SESSION['personas'] as $ind => $persona){
?>
<form action="" method="post">
<input type="text" value = <?php echo $persona['nombre']?> name = "nombre" placeholder ="Nombre">
<input type="text" value= <?php echo $persona['cedula']?> name="cedula" placeholder="Cedula">
<input type="text" value= <?php echo $persona['edad']?> name="edad" placeholder="Edad">
<input type="hidden" value=<?php echo $ind?> name="ind">
<button name="eliminar">Eliminar</button>
</form>
<?php
}
echo '<pre>';
print_r($_SESSION);
}
?>