3v4l.org

run code in 300+ PHP versions simultaneously
<?php function accum($s) { $split = str_split($s, 1); $out = ''; foreach ($split as $idx => $char) { if ($idx > 0) { $out .= '-'; } $out .= ucfirst(str_repeat($char, $idx + 1)); } return $out; } echo accum('zpglnrxqenu');
Output for 7.1.28, 7.2.18 - 7.2.33, 7.3.16 - 7.3.33, 7.4.4 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Z-Pp-Ggg-Llll-Nnnnn-Rrrrrr-Xxxxxxx-Qqqqqqqq-Eeeeeeeee-Nnnnnnnnnn-Uuuuuuuuuuu

preferences:
150.29 ms | 403 KiB | 137 Q