3v4l.org

run code in 300+ PHP versions simultaneously
<?php $input = "hello:20,test:40,abc:25"; function transform_input($input) { return array_map(function ($value) { list($title, $length) = explode(':', $value); return [ 'title' => $title, 'length' => $length ]; }, explode(',', $input)); } $array = transform_input($input); for($i=0; $i < count($array); $i++) { ?> <th><?=$array[$i]["length"]?></th> <th><?=$array[$i]["title"]?></th> <?php } ?>

preferences:
25.34 ms | 405 KiB | 5 Q