3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?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)); } } foreach ($d as $row) { $row = array_pad($row,$rows,''); foreach ($row as $colid => &$col) $col = str_pad($col, $cols[$colid]); echo implode($row," # ") . "\n"; }
Output for 5.0.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
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/ZhjZ5 on line 33
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected '&', expecting T_VARIABLE or '$' in /in/ZhjZ5 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/ZhjZ5 on line 33
Process exited with code 255.