How would I go about building output like this in PHP:
$items[] = array(
'section_name' => 'Section 1 Name',
'items' => array(
array(
'item_name' => 'Item 1 Name - Section 1'
// there will be more in here
),
array(
'item_name' => 'Item 2 Name - Section 1'
// there will be more in here
)
)
);
$items[] = array(
'section_name' => 'Section 2 Name',
'items' => array(
array(
'item_name' => 'Item 1 Name - Section 2'
// there will be more in here
),
array(
'item_name' => 'Item 2 Name - Section 2'
// there will be more in here
)
)
);
// and so on
with this as the input
[section] => Array (
[0] => Array (
[name] => Section 1 Name
[item] => Array (
[0] => Array (
[name] => Item 1 Name - Section 1
// there will be more in here
)
[1] => Array (
[name] => Item 2 Name - Section 1
// there will be more in here
)
)
)
[1] => Array (
[name] => Section 2 Name
[item] => Array (
[0] => Array (
[name] => Item 1 Name - Section 2
// there will be more in here
)
)
)
)
There will never be a set number of items in a section and the number of sections will vary too so I need something iterative then a fixed number.