I'm trying to do a simple nested array in a session variable. But I'm having a hard time wrapping my head around the logic for the dynamic creation of the arrays.
What I think my code should look like (which I know is wrong, because I want it to be dynamic):
Page 1:
session_start();
$_SESSION['test'] = array();
Page 2:
session_start();
$_SESSION['test'][0] = array('name' => 'john smith', 'age' => '20', 'city' => 'new york');
$_SESSION['test'][1] = array('name' => 'jane doe', 'age' => '42', 'city' => 'seattle');
I want to be able to do a foreach loop to grab the values
foreach($_SESSION['test'] as $test){
echo "Name " . $test['name'];
echo "Age " . $test['age'];
echo "City " . $test['city'];
}