3v4l.org

run code in 300+ PHP versions simultaneously
<?php $q = [ 'id' => 1, 'intro' => 'This is the introductory text to the question.', 'img' => ['src' => '/images/1A.png', 'alt' => 'A figure for the question.'], 'parts' => [ 'a' => [ 'text' => 'Show that this is the first part of the question.', 'subparts' => [] ], 'b' => [ 'text' => 'Show that this is the second part of the question.', 'subparts' => [ 'i' => ['text' => 'This is the subpart of question (b). Prove it.'], 'ii' => ['text' => 'This is the final subpart.'] ] ] ] ]; ?> <div class="Question" id="<?= $q['id']; ?>"> <div class="introText"> <p><?= $q['intro']; ?></p> </div> <div class="questionFigure"> <img src="<?= $q['img']['src']; ?>" alt="<?= $q['img']['alt']; ?>"> </div> <?php foreach ($q['parts'] as $a=>$part) : ?> <div class="letterQuestionText"> <p>(<?= $a; ?>) <?= $part['text']; ?></p> <?php foreach ($part['subparts'] as $i=>$subpart) : ?> <div class="romanQuestionText"> <p>(<?= $i; ?>) <?= $subpart['text']; ?></p> </div> <?php endforeach; ?> </div> <?php endforeach; ?> </div>
Output for 5.6.0 - 5.6.38, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.19, 8.3.0 - 8.3.7
<div class="Question" id="1"> <div class="introText"> <p>This is the introductory text to the question.</p> </div> <div class="questionFigure"> <img src="/images/1A.png" alt="A figure for the question."> </div> <div class="letterQuestionText"> <p>(a) Show that this is the first part of the question.</p> </div> <div class="letterQuestionText"> <p>(b) Show that this is the second part of the question.</p> <div class="romanQuestionText"> <p>(i) This is the subpart of question (b). Prove it.</p> </div> <div class="romanQuestionText"> <p>(ii) This is the final subpart.</p> </div> </div> </div>

preferences:
220.7 ms | 405 KiB | 287 Q