<?php
$content = <<<INI_ISH
[chorus]
And all will surely agree,
There's nothing like PHP.
[1]
It may not be the best way,
But it isn't going away.
[2]
When you don't appear to hack it,
Check for a closing bracket.
[bridge]
Oh, if you don't like this ode,
Then please don't look at my code.
INI_ISH;
preg_match_all(
'#^\[([^\]])[^\]]*\]\R\K(?:(?!^\[).)*$#ms',
$content,
$m
);
$map = array_combine($m[1], $m[0]);
$map[','] = "\n\n";
$sequence = '1,c,2,c,b,1,c';
echo strtr($sequence, $map);