$var = "0" x 10; $string = "test"; substr($var, -length($string)) = $string;