fork(1) download
  1. <?php
  2.  
  3. /* Initialize 'specs' array */
  4. $specs = array(
  5. "specName1" => "spec1",
  6. "specName2" => "spec2",
  7. "specName3" => "spec3",
  8. "specName4" => "spec4",
  9. "specName5" => "spec5",
  10. "specName6" => "spec6",
  11. );
  12.  
  13. /* Initialize 'tunnid' array */
  14. $tunnid = array(
  15. "value1",
  16. "value2",
  17. "value3",
  18. "value4",
  19. "value5",
  20. );
  21.  
  22. /* Create the HTML table */ ?>
  23. <table style="width: 600px" class="slicedTable">
  24. <tr>
  25. <th>Spetsialist</th>
  26. <th>Tunnid</th>
  27. </tr>
  28. <?php $len1 = count($specs); $len2 = count($tunnid);
  29. $specsKeys = array_keys($specs);
  30. for ($i = 0; $i < max($len1, $len2); $i++) {
  31. $name = ($i < $len1) ? $specsKeys[$i] : "";
  32. $value = ($i < $len2) ? $tunnid[$i] : ""; ?>
  33. <tr>
  34. <td><?php echo($name); ?></td>
  35. <td><?php echo($value); ?></td>
  36. </tr>
  37. <?php } ?>
  38. </table>
Success #stdin #stdout 0.01s 20520KB
stdin
Standard input is empty
stdout
<table style="width: 600px" class="slicedTable">
    <tr>
        <th>Spetsialist</th>
        <th>Tunnid</th>
    </tr>
    <tr>
        <td>specName1</td>
        <td>value1</td>
    </tr>
    <tr>
        <td>specName2</td>
        <td>value2</td>
    </tr>
    <tr>
        <td>specName3</td>
        <td>value3</td>
    </tr>
    <tr>
        <td>specName4</td>
        <td>value4</td>
    </tr>
    <tr>
        <td>specName5</td>
        <td>value5</td>
    </tr>
    <tr>
        <td>specName6</td>
        <td></td>
    </tr>
</table>