- str_repeat: documentation ( source)
- preg_match_all: documentation ( source)
- preg_replace: documentation ( source)
<?php
$i='4N4P19N7P1N1P2N2P';
preg_match_all('/(\d+)(\w)/',$argv[1],$m,2);
$o='';foreach($m as $p)$o.=str_repeat($p[2]=='N'?'=':'-',$p[1]);
//$a=str_repeat('_',$n=strlen($o=str_replace('--','- ',$o)));
$a=preg_replace('/./','_',$o);//=str_replace('--','- ',$o));
echo("$a\n\n\n$o\n\n$a\n");