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 5.5.0 - 5.5.38, 5.6.0 - 5.6.25, 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.27, 8.4.1 - 8.4.14, 8.5.0 - 8.5.1
<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>
Output for 8.4.15
/bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15)
Process exited with code 1.
Output for 8.3.28
/bin/php-8.3.28: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.3.28) /bin/php-8.3.28: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.3.28) /bin/php-8.3.28: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.3.28) /bin/php-8.3.28: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.3.28)
Process exited with code 1.

preferences:
206.51 ms | 408 KiB | 5 Q