本文介绍了Regexp代码用PHP替换所有“__random_anm [12,l]”rand()PHP函数[重复]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Hello ,i tried to use this code to replace any __Random_and[x,y] with rand(x,y) but it didn't run please help me
function charCallbackRand($matches1){
$charOne = (int)$matches1[1];
$charTwo = (int)$matches1[2];
return rand($charOne,$charTwo);
}
$myword = __Random_and[22,95];
$result = preg_replace_callback('/__Random_anm\[(\d+),(\d+)\]/', 'charCallbackRand', $myword);
我的尝试:
What I have tried:
function charCallbackRand($matches1){
$charOne = (int)$matches1[1];
$charTwo = (int)$matches1[2];
return rand($charOne,$charTwo);
}
$myword = __Random_and[22,95];
$result = preg_replace_callback('/__Random_anm\[(\d+),(\d+)\]/', 'charCallbackRand', $myword);
推荐答案
这篇关于Regexp代码用PHP替换所有“__random_anm [12,l]”rand()PHP函数[重复]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!