I'm trying to build my first multidimensional array - which I understand ok using hardcoded values, but trying to fill the array with values is getting me tied in knots.
I've got 2 resultsets that I'm using to build the array.
I have a method $hostnames that returns all 'hostnames' as an object
$hostnames = $server_model->get_hostnames();
I have a method $usernames that returns all 'users' of the 'hostname' that is specified above.
$usernames = $userlogons_model->get_users_by_hostname($hostname->hostname);
First, I'm building the array:
$hostnames = array(
$host => $hostname,
$users => array(
$key => $username
)
);
Then I am populating the arrays:
$hostnames = $server_model->get_hostnames_for_costs();
foreach ($hostnames as $hostname) {
$usernames = $userlogons_model->get_users_by_hostname($hostname);
echo $hostname->hostname;
foreach ($usernames as $user){
echo $user->username;
}
}
My editor is showing undefined variables where I'm declaring the arrays in the first block. I'm getting no output - Surely a syntax error and I'm struggling. Help would be appreciated !
Cheers, Mike