3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = array( array('Title 1'=>'text11', 'Title 2'=>'text12'), array('Title 1'=>'text21', 'Title 2'=>'text22'), array('Title 1'=>'text31', 'Title 2'=>'text32'), array('Title 1'=>'text41', 'Title 2'=>'text42', 'special'=>'style1'), array('Title 1'=>'text51', 'Title 2'=>'text52', 'special'=>'style2'), ); ?> <table> <thead> <tr> <th>Title 1</th> <th>Title 2</th> </tr> </thead> <tbody> <?php foreach ($data as $key=>$row): if (isset($row["special"])) { $class = " class='" . $row["special"]. "'"; unset($row["special"]); } else { $class=''; }?> <tr<?php echo $class ?>> <td><?php echo implode('</td><td>', $row); ?></td> </tr> <?php endforeach; ?> </tbody> </table>
Output for 5.6.0 - 5.6.24, 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 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.28, 8.4.1 - 8.4.14, 8.5.0 - 8.5.1
<table> <thead> <tr> <th>Title 1</th> <th>Title 2</th> </tr> </thead> <tbody> <tr> <td>text11</td><td>text12</td> </tr> <tr> <td>text21</td><td>text22</td> </tr> <tr> <td>text31</td><td>text32</td> </tr> <tr class='style1'> <td>text41</td><td>text42</td> </tr> <tr class='style2'> <td>text51</td><td>text52</td> </tr> </tbody> </table>
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.

preferences:
200.26 ms | 408 KiB | 5 Q