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
你能發表一個原始字符串的例子嗎? –