3v4l.org

run code in 300+ PHP versions simultaneously
<?php $value ='xyz:101,xyz:102,xyz:103,xyz:104,xyz:105,ABC:201,xyz:202,xyz:203,xyz:204,xyz:205'; $rows = explode(',', $value); ?> <table width='50%' border='1' cellpadding='10' cellspacing='10'> <tr> <th>Category</th> <th>Code</th> </tr> <?php foreach ($rows as $row) { $values = explode(':', $row); ?> <tr> <td><?php echo $values[0]; ?></td> <td><?php echo $values[1]; ?></td> </tr> <?php } ?> </table>
Output for 4.3.0 - 4.3.11, 4.4.0 - 4.4.9, 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.0 - 5.5.38, 5.6.0 - 5.6.30, 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.25, 8.4.1 - 8.4.12
<table width='50%' border='1' cellpadding='10' cellspacing='10'> <tr> <th>Category</th> <th>Code</th> </tr> <tr> <td>xyz</td> <td>101</td> </tr> <tr> <td>xyz</td> <td>102</td> </tr> <tr> <td>xyz</td> <td>103</td> </tr> <tr> <td>xyz</td> <td>104</td> </tr> <tr> <td>xyz</td> <td>105</td> </tr> <tr> <td>ABC</td> <td>201</td> </tr> <tr> <td>xyz</td> <td>202</td> </tr> <tr> <td>xyz</td> <td>203</td> </tr> <tr> <td>xyz</td> <td>204</td> </tr> <tr> <td>xyz</td> <td>205</td> </tr> </table>

preferences:
136.58 ms | 412 KiB | 5 Q