0
我有一个很长的字符串,包含几个“*”字符,我想找到所有这些字符,并替换他们+后8个字符,并用花药字符串替换它们。做这个的最好方式是什么?这就是我试图做:你想要去PHP找到并替换字符串后特定字符
$over_string=strlen($story)-1;
for ($i=0; $i<$over_string; $i++){
if($story[$i]=='*'){
$id_substr=substr($story, $i+1,8);
$name_player_change=some_function($id_substr);
$id_to_replace='*'.$id_substr;
$name_to_place='<a href="#">'.$name_player_change.'</a>';
$story=str_replace($id_to_replace,$name_to_place,$story);
}//if
}//for
你能发表一个原始字符串的例子吗? –