Here's a small example to show how to loop everything:
PHP Code:
<?php
// Just repeating text for example.
$textbook = array(
'cantonese' => array(
'class1' => array(
1 => array('One - Two', 'Chapter 1 to Chapter 2', 'text'),
3 => array('Three - Five', 'Chapter 3 to Chapter 5', 'text'),
6 => array('Six - Eight', 'Chapter 6 to Chapter 8', 'text'),
),
'class2' => array(
1 => array('One - Two', 'Chapter 1 to Chapter 2', 'text'),
3 => array('Three - Five', 'Chapter 3 to Chapter 5', 'text'),
6 => array('Six - Eight', 'Chapter 6 to Chapter 8', 'text'),
)
),
'mandarin' => array(
'class1' => array(
1 => array('One - Two', 'Chapter 1 to Chapter 2', 'text'),
3 => array('Three - Five', 'Chapter 3 to Chapter 5', 'text'),
6 => array('Six - Eight', 'Chapter 6 to Chapter 8', 'text'),
),
'class2' => array(
1 => array('One - Two', 'Chapter 1 to Chapter 2', 'text'),
3 => array('Three - Five', 'Chapter 3 to Chapter 5', 'text'),
6 => array('Six - Eight', 'Chapter 6 to Chapter 8', 'text'),
)
)
);
?>
<!-- Some styling for better understanding -->
<style type="text/css">
div {
margin-left: 2em;
}
</style>
<?php
foreach($textbook as $lang => $langdata) { // Loop languages
echo '<h2>'.ucfirst($lang).'</h2><div>';
foreach($langdata as $class => $classdata) { // Loop classes
echo '<h3>'.ucfirst($class).'</h3><div>';
foreach($classdata as $chapter => $chapterdata) { // Loop chapters
echo '<h4>Chapter '.$chapter.' - '.$chapterdata[0].'</h4><div><span style="font-style: italic;">'.$chapterdata[1].'</span><p>'.$chapterdata[2].'</p></div>';
}
echo '</div>';
}
echo '</div>';
}
?>
Example output