3v4l.org

run code in 300+ PHP versions simultaneously
<?php $d = array( array( "id", "int(10) unsigned", "NO", "PRI", "auto_increment" ), array( "title", "varchar(32)", "NO" ), array( "author", "varchar(32)", "NO" ), array( "category", "tinyint(3) unsigned", "NO" ), array( "date", "datetime", "NO" ), array( "post_ip", "int(10) unsigned", "NO" ), array( "approved_by", "varchar(32)", "NO" ), array( "text", "text", "NO" ) ); $cols = array(); $rows = 0; foreach ($d as $row) { ($rows < count($row) && $rows = count($row)); foreach($row as $id => $col) { (!isset($cols[$id]) && $cols[$id] = 0); ($cols[$id] < strlen($col) && $cols[$id] = strlen($col)); } } print_R($cols); foreach ($d as $row) { foreach ($row as $colid => &$col) $col = str_pad($col, $cols[$colid]); echo implode($row," # ") . "\n"; } /* id # int(10) unsigned # NO # PRI # auto_increment # [19:44] <teehee> title # varchar(32) # NO # [19:44] <teehee> author # varchar(32) # NO # [19:44] <teehee> category # tinyint(3) unsigned # NO # [19:44] <teehee> date # datetime # NO # [19:44] <teehee> post_ip # int(10) unsigned # NO # [19:44] <teehee> approved_by # varchar(32) # YES # [19:44] <teehee> text # text # NO # */
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Array ( [0] => 11 [1] => 19 [2] => 2 [3] => 3 [4] => 14 ) Fatal error: Uncaught TypeError: implode(): Argument #2 ($array) must be of type ?array, string given in /in/Fs4G5:35 Stack trace: #0 /in/Fs4G5(35): implode(Array, ' # ') #1 {main} thrown in /in/Fs4G5 on line 35
Process exited with code 255.
Output for 7.4.0 - 7.4.25, 7.4.27 - 7.4.33
Array ( [0] => 11 [1] => 19 [2] => 2 [3] => 3 [4] => 14 ) Deprecated: implode(): Passing glue string after array is deprecated. Swap the parameters in /in/Fs4G5 on line 35 id # int(10) unsigned # NO # PRI # auto_increment Deprecated: implode(): Passing glue string after array is deprecated. Swap the parameters in /in/Fs4G5 on line 35 title # varchar(32) # NO Deprecated: implode(): Passing glue string after array is deprecated. Swap the parameters in /in/Fs4G5 on line 35 author # varchar(32) # NO Deprecated: implode(): Passing glue string after array is deprecated. Swap the parameters in /in/Fs4G5 on line 35 category # tinyint(3) unsigned # NO Deprecated: implode(): Passing glue string after array is deprecated. Swap the parameters in /in/Fs4G5 on line 35 date # datetime # NO Deprecated: implode(): Passing glue string after array is deprecated. Swap the parameters in /in/Fs4G5 on line 35 post_ip # int(10) unsigned # NO Deprecated: implode(): Passing glue string after array is deprecated. Swap the parameters in /in/Fs4G5 on line 35 approved_by # varchar(32) # NO Deprecated: implode(): Passing glue string after array is deprecated. Swap the parameters in /in/Fs4G5 on line 35 text # text # NO
Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.24 - 5.5.35, 5.6.8 - 5.6.21, 7.0.0 - 7.0.20, 7.1.0 - 7.1.7, 7.2.0 - 7.2.33, 7.3.12 - 7.3.33, 7.4.26
Array ( [0] => 11 [1] => 19 [2] => 2 [3] => 3 [4] => 14 ) id # int(10) unsigned # NO # PRI # auto_increment title # varchar(32) # NO author # varchar(32) # NO category # tinyint(3) unsigned # NO date # datetime # NO post_ip # int(10) unsigned # NO approved_by # varchar(32) # NO text # text # NO
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected '&', expecting T_VARIABLE or '$' in /in/Fs4G5 on line 33
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1
Parse error: parse error, unexpected '&', expecting T_VARIABLE or '$' in /in/Fs4G5 on line 33
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_VARIABLE' or `'$'' in /in/Fs4G5 on line 33
Process exited with code 255.

preferences:
200.77 ms | 405 KiB | 312 Q