For Each on Array?
Posted: Sun Jan 23, 2011 5:43 pm
Hi Guys,
I'm trying to implement user permissions. I have a site that will have user permissions set for each site.
so
$_SESSION['user_permissions']['new york']['edit_files'] = 1
$_SESSION['user_permissions']['new york']['admin_files'] = 1
$_SESSION['user_permissions']['boston']['edit_files'] = 1
Would be the output.
The user permissions are stored in a table where one row is equivalent to a location (e.g. new york or boston) and the admin_files / user_files are colums thus allowing me to expand the range of user permissions without too much coding. Now I know the code below is wrong as you can refer to $row inside the foreach but can anyone give me a pointer onto how to manage this?
Cheers
Richard
I'm trying to implement user permissions. I have a site that will have user permissions set for each site.
so
$_SESSION['user_permissions']['new york']['edit_files'] = 1
$_SESSION['user_permissions']['new york']['admin_files'] = 1
$_SESSION['user_permissions']['boston']['edit_files'] = 1
Would be the output.
The user permissions are stored in a table where one row is equivalent to a location (e.g. new york or boston) and the admin_files / user_files are colums thus allowing me to expand the range of user permissions without too much coding. Now I know the code below is wrong as you can refer to $row inside the foreach but can anyone give me a pointer onto how to manage this?
Cheers
Richard
Code: Select all
foreach ($row as $key => $value) {
if($value > 0) {
$_SESSION['user_Permissions'][$row['up_Site']][$key] = $value;
}
}