3v4l.org

run code in 300+ PHP versions simultaneously
<?php define('ROWS_PER_PAGE', 10); function display_table($fields, $data, $rows, $page){ if(isset($_GET['page'])){ $page = $_GET['page']; } else { $page = 1; } $firstRecord = ($page - 1) * ROWS_PER_PAGE; $pageNumbers = ceil($rows / ROWS_PER_PAGE); echo '<div class="table-responsive w-75 mx-auto py-3"> <table class="table table-dark table-bordered table-sm"> <thead> <tr>'; foreach($fields as $key){ echo '<th class="py-2">' . $key . '</th>'; } echo '</tr> </thead> </tbody>'; $keys = array_keys($fields); $lastRecord = min($firstRecord + ROWS_PER_PAGE, $rows); for($record = $firstRecord; $record < $lastRecord; $record++){ $row = $data[$record]; echo '<tr>'; for($recordCount = 0; $recordCount < count($keys); $recordCount++){ $column = $keys[$recordCount]; echo '<td class="py-2">' . $row[$column] . '</td>'; } echo '</tr>'; } echo '</tbody> </table'; for($pages = 1; $pages <= $pageNumbers; $pages++){ echo '<a class="btn btn-dark mx-1" href=?page=' . $pages . '</a>'; } } $fields = array( "id" => "Id", "emailaddress" => "Email", "firstname" => "First Name", "lastname" => "Last Name", "salesperson" => "Salesperson", "phonenumber" => "Phone Number", "extension" => "Extension", "type" => "Type" ); $data = array( array('id' => 1, 'emailaddress' => 'user1@example.com', 'firstname' => 'User', 'lastname' => 'One', 'salesperson' => 'y', 'phonenumber' => '1235556789', 'extension' => '1', 'type' => 'a') , array('id' => 2, 'emailaddress' => 'user2@example.com', 'firstname' => 'User', 'lastname' => 'Two', 'salesperson' => 'y', 'phonenumber' => '1235556789', 'extension' => '2', 'type' => 'a') ); display_table($fields, $data, 2, 1);
Output for git.master, git.master_jit, rfc.property-hooks
<div class="table-responsive w-75 mx-auto py-3"> <table class="table table-dark table-bordered table-sm"> <thead> <tr><th class="py-2">Id</th><th class="py-2">Email</th><th class="py-2">First Name</th><th class="py-2">Last Name</th><th class="py-2">Salesperson</th><th class="py-2">Phone Number</th><th class="py-2">Extension</th><th class="py-2">Type</th></tr> </thead> </tbody><tr><td class="py-2">1</td><td class="py-2">user1@example.com</td><td class="py-2">User</td><td class="py-2">One</td><td class="py-2">y</td><td class="py-2">1235556789</td><td class="py-2">1</td><td class="py-2">a</td></tr><tr><td class="py-2">2</td><td class="py-2">user2@example.com</td><td class="py-2">User</td><td class="py-2">Two</td><td class="py-2">y</td><td class="py-2">1235556789</td><td class="py-2">2</td><td class="py-2">a</td></tr></tbody> </table<a class="btn btn-dark mx-1" href=?page=1</a>

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:
74.92 ms | 403 KiB | 8 Q