Click to See Complete Forum and Search --> : array help


jrthor2
11-17-2003, 08:16 AM
I have page that lists users that are allowed to approve something when a user enters a press release. When trying to show the list of approvers, it is not showing anything. below is my array of users:

$users['prgjr1']=array(add=>'y',edit=>'y', delete=>'y',approve=>'y',allcats=>'y',national_financial=>'y',people=>'y',investor=>'y',community=>'y');
$users['prgjxy']=array(add=>'y',edit=>'y', delete=>'y',approve=>'y',allcats=>'y',national_financial=>'y',people=>'y',investor=>'y',community=>'y');
$users['rssdbr']=array(add=>'y',edit=>'y', delete=>'y',approve=>'y',allcats=>'y',national_financial=>'y',people=>'y',investor=>'y',community=>'y');
$users['admgyr']=array(add=>'y',edit=>'y', delete=>'y',approve=>'y',allcats=>'y',national_financial=>'y',people=>'y',investor=>'y',community=>'y');
$users['prdjhc']=array(add=>'y',edit=>'y', delete=>'y',approve=>'y',allcats=>'y',national_financial=>'y',people=>'y',investor=>'y',community=>'y');
$users['prdkar']=array(add=>'y',edit=>'y', delete=>'y',approve=>'y',allcats=>'y',national_financial=>'y',people=>'y',investor=>'y',community=>'y');

Here is the code I am using to display the users that have rights to approve:


for(reset($users);$key=key($users);next($users)) {

if ($users[$key][approve] == "y") {
$user_name = $users[$key][name];
print $user_name . "<br>";
}
}



I'm not sure why it is not displaying all the users with approve = y. Can someone help?

Thanks

YoN
11-18-2003, 11:40 AM
Where have you set the name of each of the members that you are trying to display??
As it seems, $users[$key][name] won't assign anything to $user_name since that key [name] doesn't exist in the array.
Also i'm not quite sure if the way you declare the arrays are well but better try doing it like:
<?php
$users["prgjr1"]=array("add"=>"y", "edit"=>"y", "delete"=>"y", "approve"=>"y", "allcats"=>"y", "national_financial"=>"y", "people"=>"y", "investor"=>"y", "community"=>"y");
?>


HTH.