PDA

View Full Version : Array question


Lionel
08-06-2006, 12:03 AM
I am able to get those values in an array

Array ( [0] => stdClass Object ( [id] => 4 [roleid] => 4 [name] => Free [chat] => 0 [forum] => 1

How can I extract them so I can do

$_SESSION['security'][roleid]=4;
$_SESSION['security'][name]=Free;

etc for each one of them?

foreach ($security as $k=>$v)
is not returning anything but the first one '0' without even the name.

Here is the full query

$database->setQuery("SELECT * FROM membership WHERE roleid = '$_SESSION[RoleId]'");
$security = $database->loadObjectList();
print_r($security);

Thanks.

Code Monkey
08-06-2006, 12:22 AM
That is a multidimensional array. Is there more than 1 sub array?

If so try
foreach ($security[0] as $k=>$v)

if not then


foreach ($security as $val)
{
foreach ($val as $k=>$v)
{

}

}

Lionel
08-06-2006, 12:34 AM
both methods work. Thanks a million!!