Heim > Artikel > Backend-Entwicklung > preg_replace_callback 中 function($match) use ($ten), 里面的 use 是什么意义
preg_replace_callback 中 function($match) use ($ten), 里面的 use 是什么意思
$string = "Some numbers: one: 1; two: 2; three: 3 end";<br />$ten = 10;<br />$newstring = preg_replace_callback(<br /> '/(\\d+)/',<br /> function($match) use ($ten) { return (($match[0] + $ten)); },<br /> $string<br /> );<br />echo $newstring;
$string = "Some numbers: one: 1; two: 2; three: 3 end";<br />$ten = 10;<br />$newstring = preg_replace_callback(<br /> '/(\\d+)/',<br /> create_function('$match', "return \$match[0] + $ten;"),<br /> $string<br /> );<br />echo $newstring;