I have a long string that contain few "*" chars, I want to find all those chars and replace them+the 8 chars after them, And replace them with anther string. What is the best way to do this? this is how i tried to do:
$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