3v4l.org

run code in 300+ PHP versions simultaneously
<?php $fake_db_results = [ ['session_id' => 1, 'page_url' => 'http://a.com'], ['session_id' => 1, 'page_url' => 'http://b.com'], ['session_id' => 1, 'page_url' => 'http://c.com'], ['session_id' => 2, 'page_url' => 'http://d.com'], ['session_id' => 2, 'page_url' => 'http://e.com'], ['session_id' => 3, 'page_url' => 'http://f.com'], ['session_id' => 4, 'page_url' => 'http://g.com'], ['session_id' => 5, 'page_url' => 'http://h.com'] ]; $paths = []; foreach ($fake_db_results as $row) { if ( ! array_key_exists($row['session_id'], $paths) || ! is_array($paths[$row['session_id']])) { $paths[$row['session_id']] = []; } array_push($paths[$row['session_id']], $row['page_url']); } echo '<pre>'; var_dump($paths); $html = ''; foreach ($paths as $session => $page) { $html .= "<tr>\n"; $html .= '<td>' . $session . "</td>\n"; $html .= '<td>' . implode('| ', $page) . "</td>\n"; $html .= "</tr>\n"; } echo $html;
Output for git.master, git.master_jit, rfc.property-hooks
<pre>array(5) { [1]=> array(3) { [0]=> string(12) "http://a.com" [1]=> string(12) "http://b.com" [2]=> string(12) "http://c.com" } [2]=> array(2) { [0]=> string(12) "http://d.com" [1]=> string(12) "http://e.com" } [3]=> array(1) { [0]=> string(12) "http://f.com" } [4]=> array(1) { [0]=> string(12) "http://g.com" } [5]=> array(1) { [0]=> string(12) "http://h.com" } } <tr> <td>1</td> <td>http://a.com| http://b.com| http://c.com</td> </tr> <tr> <td>2</td> <td>http://d.com| http://e.com</td> </tr> <tr> <td>3</td> <td>http://f.com</td> </tr> <tr> <td>4</td> <td>http://g.com</td> </tr> <tr> <td>5</td> <td>http://h.com</td> </tr>

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:
51.37 ms | 407 KiB | 5 Q