3v4l.org

run code in 300+ PHP versions simultaneously
<?php $i='4N4P9N7P1N1P2N2P'; preg_match_all('/(\d+)(\w)/',$i,$m,2); print_r($m); foreach($m as $p) { if ($p[2]=='N') { $o.=str_repeat('=',$p[1]); } else { $o.=str_repeat('- ',(int)($p[1]/2)).($p%2?'-':''); } } echo($o);

preferences:
38.9 ms | 402 KiB | 5 Q