关于网友提出的“preg_replace替换为preg_replace_callback”问题疑问,本网通过在网上对“preg_replace替换为preg_replace_callback”有关的相关答案进行了整理,供用户进行参考,详细问题解答如下:
问题:preg_replace替换为preg_replace_callback
描述:
preg_replace(array('/(^|_|-)+(.)/e', '/\.(.)/e'), array("strtoupper('\\2')", "'_'.strtoupper('\\1')"), $id);
各位为大神,替换为preg_replace_callback怎么写啊
解决方案1:
$id = preg_replace_callback('/(^|_|-)+(.)/', function($m) { return strtoupper($m[2]); }, $id);
$id = preg_replace_callback('/\.(.)/', function($m) { return '_' . strtoupper($m[1]); }, $id);
echo $id;
以上介绍了“preg_replace替换为preg_replace_callback”的问题解答,希望对有需要的网友有所帮助。
本文网址链接:http://www.codes51.com/itwd/948498.html