How to structurally display a multi-dimensional array in PHP?
- by Jaime Cross
How can I display the contents of an array as follows:
Company Name
- Username1
- Username2
Another Company Name
- Username3
The array I have created is as follows:
$array[1]['company_id'] = '12';
$array[1]['company_name'] = 'ABC Company';
$array[1]['company_type'] = 'default';
$array[1]['user_id'] = '23';
$array[1]['user_name'] = 'Andrew';
$array[2]['company_id'] = '12';
$array[2]['company_name'] = 'ABC Company';
$array[2]['company_type'] = 'default';
$array[2]['user_id'] = '27';
$array[2]['user_name'] = 'Jeffrey';
$array[3]['company_id'] = '1';
$array[3]['company_name'] = 'Some Company';
$array[3]['company_type'] = 'default';
$array[3]['user_id'] = '29';
$array[3]['user_name'] = 'William';
$array[4]['company_id'] = '51';
$array[4]['company_name'] = 'My Company';
$array[4]['company_type'] = 'default';
$array[4]['user_id'] = '20';
$array[4]['user_name'] = 'Jaime';