This is what you want
$mystring = "This is a text1 i want to replace before # text2 i want to replace before # text3";
$start = "text1";
$end = "#";
$replace= "@@@@@@";
$pos1 = strpos($mystring, $start);
$pos2 = strpos($mystring, $end, $pos1);
$length=$pos2+ strlen($end) - $pos1;
$result = substr_replace($mystring,$replace,$pos1,$length);
echo $result;
What I have done here is find the string positions. $pos1 & $pos2 are the the positions of your start and ending string.
Then calculated the length between those two strings where strlen($end) is the length of your ending string (so that we can grab the end string also).
Finally just used the regular substr_replace function.
Hope this helps you.