So I have the following string.
John Hotmail(johnhotmail@hotmail.com) , John Hotmail(johnhotmail@hotmail.com) ,
I am trying replace only the first instance of the above John Hotmail however no matter what I try it replaces both. I have looking through the forums for an answer and I have already attempted all of the solutions. I have tried the following.
$string= "/John Hotmail(johnhotmail@hotmail.com) ,/";
//$string= "John Hotmail(johnhotmail@hotmail.com) ,";
$count = 1;
$descriptionMessage = $name . ' said hello' . $model->Name . ' to the following people:' . $listParticipants;
$descriptionMessage = preg_replace($string, "", $descriptionMessage,$count);
I have tried similar things with str_replace. I have changed the string message to contain / as well as to have no / in it. I have put count to 0 in which case it does not strip anything out and I have put it to 1 as above which removes both John Hotmail strings. None of the settings I have entered have just removed the first occurance however and I do not know why. I am currently using this code in a controller class of the Yii Framework if that helps. Thanks for any help.
This will replace the first occurrence: