3v4l.org

run code in 200+ php & hhvm versions
<?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.0.33 - 7.2.18
Z-Pp-Ggg-Llll-Nnnnn-Rrrrrr-Xxxxxxx-Qqqqqqqq-Eeeeeeeee-Nnnnnnnnnn-Uuuuuuuuuuu