I am just learning php and I just don't understand how to do something that seems should be quite simple.
I have an array with these fields
I need to create a session array that summarizes the array data - county - state - income - count
I just don't know how to create a new Session array to hold the above data. I have searched and tried but I don't get any closer. I think I need to have an associative array.
I recomend that you take a look at How to create, Access and Destroy PHP session .
As mentioned in the commets above, you may set an your $_SESSION
superglobal like:
// Start the session if it is not already started
if(!session_id()) {
session_start();
}
// Set the session variables
$_SESSION = [
'date' => 'value1',
'income' => 'value2',
'county' => 'value2',
'state' => 'value2',
'count ' => 1,
...
];
You may also set your session like:
// Start the session if it is not already started
if(!session_id()) {
session_start();
}
// Set the session variables
$_SESSION['date'] = 'value1';
$_SESSION['income'] = 'value2';
$_SESSION['county'] = 'value2';
$_SESSION['state'] = 'value2';
$_SESSION['count '] = 1;
Hope this helps,
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.