preg_replace_callback_array(patterns, input, limit, count)
演示
<html> <head> <title> PHP 7 Featuretutorialpoint:</title> </head> <body> <?php $subject = 'AaaaaaaBbbbCccc'; preg_replace_callback_array ( [ '~[a]+~i' => function ($match) { echo strlen($match[0]), ' number of "a" found', PHP_EOL; }, '~[b]+~i' => function ($match) { echo strlen($match[0]), ' number of "b" found', PHP_EOL; }, '~[c]+~i' => function ($match) { echo strlen($match[0]), ' number of "c" found', PHP_EOL; } ], $subject ); ?> </body> </html>
上述程序代码的输出为 −
7 number of "a" found 4 number of "b" found 5 number of "c" found
以上就是PHP 7中的preg_replace_callback_array()函数的详细内容,更多请关注php中文网其它相关文章!