How can substr_replace be used to customize string replacements in PHP?
When using substr_replace in PHP, you can customize string replacements by specifying the start position and length of the substring you want to replace. This allows you to target specific parts of a string for replacement, rather than replacing the entire string.
<?php
$string = "Hello, world!";
$replacement = "PHP";
$start = 7;
$length = 5;
$new_string = substr_replace($string, $replacement, $start, $length);
echo $new_string; // Output: Hello, PHP!
?>