The problem:
To create a recursive array function that walks through a three dimensional array and print out the content according to the format below. As illustrated in the desired output/goal, the code for the different questions is the same.
The array:
$items = array (
'What is your gender?' => array
(
'gender' => array
(
'1' => 'Man',
'2' => 'Woman'
)
),
'What is your education?' => array
(
'education' => array
(
'1' => 'Elementary school',
'2' => 'Middle school',
'3' => 'High school',
'4' => 'Post-secondary education (BSc, MSc)',
'5' => 'Advanced education (PhD)'
)
)
);
Desired output/goal:
<div class="control-group">
<label class="control-label"><strong>What is your gender?</strong></label>
<div class="controls">
<label class="radio">
<input type="radio" name="gender" id="gender" value="1" checked>
Man
</label>
<label class="radio">
<input type="radio" name="gender" id="gender" value="2">
Woman
</label>
</div>
</div>
<div class="control-group">
<label class="control-label"><strong>What is your education?</strong></label>
<div class="controls">
<label class="radio">
<input type="radio" name="education" id="education" value="1" checked>
Elementary school
</label>
<label class="radio">
<input type="radio" name="education" id="education" value="2">
Middle school
</label>
<label class="radio">
<input type="radio" name="education" id="education" value="3">
High school
</label>
<label class="radio">
<input type="radio" name="education" id="education" value="4">
Post-secondary education (BSc, MSc)
</label>
<label class="radio">
<input type="radio" name="education" id="education" value="5">
Advanced education (PhD)
</label>
</div>
</div>