ついでに正規表現パターンにPOSTデータ突っ込むのがどうしても我慢ならなかったから直してみた

$line = preg_replace_callback(
'!<a href="\.\./test/read\.php/(?<bbs>[^/]+)/(?<key>[^/]+)/(?<num>[\d|\-]+)" target="_blank">&gt;&gt;\k<num></a>!',
function ($matches) use ($del) {
$bbs = filter_input(INPUT_POST, 'bbs');
$key = filter_input(INPUT_POST, 'key');
if ($matches['bbs'] !== $bbs || $matches['key'] !== $key) {
return $matches[0];
}
return '<a href="../test/read.php/'.$bbs.'/'.$key.'/'.res_num($matches['num'], $del).'" target="_blank">&gt;&gt;'.res_num($matches['num'], $del).'</a>';
},
$line
);