0532デフォルトの名無しさん (ワッチョイ 0b5b-hE18)
2018/08/22(水) 10:16:38.53ID:mlQDc+9J0$line = preg_replace_callback(
"!<a href=\"\.\./test/read\.php/$_POST['bbs']/$_POST['key']/([\d|\-]+)\" target=\"_blank\">>>([\d|\-]+)</a>!",
'callback_hoge', $line);
function callback_hoge($matches)
{
return "<a href=\"../test/read.php/$_POST['bbs']/$_POST['key']/" . res_num($matches[1], $del). '\" target=\"_blank\">>>' . res_num($matches[2], $del) . '</a>';
}
クロージャ使って書くなら
$line = preg_replace_callback(
"!<a href=\"\.\./test/read\.php/$_POST['bbs']/$_POST['key']/([\d|\-]+)\" target=\"_blank\">>>([\d|\-]+)</a>!",
function ($matches) {
return "<a href=\"../test/read.php/$_POST['bbs']/$_POST['key']/" . res_num($matches[1], $del). '\" target=\"_blank\">>>' . res_num($matches[2], $del) . '</a>';
},
$line
);
半角スペース2個を全角スペースにして書いてるので注意