Replace preg_replace() e modifier with preg_replace_callback

后端 未结 3 1276
醉梦人生
醉梦人生 2020-11-21 05:33

I\'m terrible with regular expressions. I\'m trying to replace this:

public static function camelize($word) {
   return preg_replace(\'/(^|_)([a-z])/e\', \'s         


        
3条回答
  •  孤城傲影
    2020-11-21 06:22

    You shouldn't use flag e (or eval in general).

    You can also use T-Regx library

    pattern('(^|_)([a-z])')->replace($word)->by()->group(2)->callback('strtoupper');
    

提交回复
热议问题