string substr_replace ( string $string, string $replace, int $start [ , int $length ] )
substr_replace() replaces a copy of string delimited by the start and (optionally) length parameter with the string given in replacement
※ available F/W version : all
Returns the result string
<?php
$str = "Hello PHPoC!";
$ret = substr_replace($str, "Hi", 0, 5); echo "$ret\r\n"; // OUTPUT: Hi PHPoC!
$ret = substr_replace($str, "Hi", -12, 5); echo "$ret\r\n"; // OUTPUT: Hi PHPoC!
$ret = substr_replace($str, "Hi", 0, -7); echo "$ret\r\n"; // OUTPUT: Hi PHPoC!
$ret = substr_replace($str, "Hi", 6); echo "$ret\r\n"; // OUTPUT: Hello Hi
$str = "";
$ret = substr_replace($str, "Hi", 6); echo "$ret\r\n"; // OUTPUT: Hi
?>
str_repeat() / strpos() / str_replace() / substr()
This function is identical to the PHP group’s substr() function but it doesn’t support array.