返り値

注意

例

例1 mb_ereg_replace_callback() の例

<?php// this text was used in 2002// we want to get this up to date for 2003$text = "April fools day is 04/01/2002\n";$text.= "Last christmas was 12/24/2001\n";// the callback functionfunction next_year($matches){// as usual: $matches[0] is the complete match // $matches[1] the match for the first subpattern // enclosed in '(...)' and so onreturn $matches[1].($matches[2]+1);}echo mb_ereg_replace_callback("(\d{2}/\d{2}/)(\d{4})","next_year",$text);

?>

上の例の出力は以下となります。

April fools day is 04/01/2003
Last christmas was 12/24/2002

例2 PHP 5.3.0以降でサポートされる匿名関数を使用したmb_ereg_replace_callback()の例

<?php// this text was used in 2002// we want to get this up to date for 2003$text = "April fools day is 04/01/2002\n";$text.= "Last christmas was 12/24/2001\n";