function updatetag($start, $end, $text, $data) { $pos1 = strpos($text, $start); if(!is_integer($pos1)) { $res = $text.$start.$data.$end; return $res; } $pos1 += strlen($start); $pos2 = strpos($text, $end, $pos1); if(!is_integer($pos2)) { $pos = false; return false; } $t1 = substr($text, 0, $pos1); $t2 = substr($text, $pos2); $res = $t1.$data.$t2; return $res; }