3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getTableHtml(array $data, int $colLength): string { $result = ''; $rowNumber = 0; $rows = []; foreach (array_values($data) as $k => $v) { if ($k % $colLength === 0) { ++$rowNumber; $rows[$rowNumber] = ''; } $rows[$rowNumber] .= '<td>'; $rows[$rowNumber] .= htmlentities($v); $rows[$rowNumber] .= '</td>'; $rows[$rowNumber] .= PHP_EOL; // optional formatting } $result = '<table><tr>' . join('</tr><tr>', $rows) . '</tr></table>'; return $result; } $array = [ "1", "2", "3", "4", "5", "6", "7", "8", "9", "10" ]; echo getTableHtml($array, 4), PHP_EOL;
Output for git.master, git.master_jit, rfc.property-hooks
<table><tr><td>1</td> <td>2</td> <td>3</td> <td>4</td> </tr><tr><td>5</td> <td>6</td> <td>7</td> <td>8</td> </tr><tr><td>9</td> <td>10</td> </tr></table>

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:
31.17 ms | 405 KiB | 5 Q