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 } ?>
Output for 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.4, 8.3.6 - 8.3.25, 8.4.1 - 8.4.12
<th>20</th> <th>hello</th> <th>40</th> <th>test</th> <th>25</th> <th>abc</th>
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 <th>20</th> <th>hello</th> <th>40</th> <th>test</th> <th>25</th> <th>abc</th>

preferences:
126.86 ms | 408 KiB | 5 Q