3v4l.org

run code in 300+ PHP versions simultaneously
<?php // $result = $conn->query("SELECT content, sub_content FROM objectives"); $result = [ ["content" => "Demonstrate where to find the following documentation:", "sub_content" => "Operating and Safety Strategy"], ["content" => "Explain the different turbine main operating states:", "sub_content" => "0"], ["content" => "Explain the different turbine main operating states:", "sub_content" => "Power Production"], ["content" => "Explain the different turbine main operating states:", "sub_content" => "Idle"], ["content" => "Explain the different turbine main operating states:", "sub_content" => "Stop"], ["content" => "Explain how to recognise the current operating mode on the display of the operating panel", "sub_content" => "0"], ["content" => "Explain the subsystem operating modes:", "sub_content" => "Stop"], ["content" => "Explain the subsystem operating modes:", "sub_content" => "Manual"], ["content" => "Explain the subsystem operating modes:", "sub_content" => "0"], ["content" => "Explain the difference between local and remote point of operation", "sub_content" => "0"], ["content" => "Explain that only one point of operation can be active at a time", "sub_content" => "0"] ]; $category = null; $output = ''; foreach ($result as $row) { if ($category !== $row['content']) { // new parent if ($category !== null) { // not first iteration $output .= "\t<li>$category"; // print parent if ($sublist) { $output .= "\n\t\t<ul>$sublist\n\t\t</ul>\n\t"; // print all children } $output .= "</li>\n"; } $category = $row['content']; // overwrite $category $sublist = ''; // reset sublist } if ($row['sub_content'] !== '0'){ // filter row $sublist .= "\n\t\t\t<li>{$row['sub_content']}</li>"; } } if ($result) { // in case the resultset is empty echo "<ul>\n"; echo $output; // print stored markup echo "\t<li>$category"; // print last parent if ($sublist) { echo "\n\t\t<ul>$sublist\n\t\t</ul>\n\t"; // print all children from last parent } echo "</li>\n"; echo "</ul>"; }
Output for git.master, git.master_jit, rfc.property-hooks
<ul> <li>Demonstrate where to find the following documentation: <ul> <li>Operating and Safety Strategy</li> </ul> </li> <li>Explain the different turbine main operating states: <ul> <li>Power Production</li> <li>Idle</li> <li>Stop</li> </ul> </li> <li>Explain how to recognise the current operating mode on the display of the operating panel</li> <li>Explain the subsystem operating modes: <ul> <li>Stop</li> <li>Manual</li> </ul> </li> <li>Explain the difference between local and remote point of operation</li> <li>Explain that only one point of operation can be active at a time</li> </ul>

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
162.63 ms | 407 KiB | 5 Q