How can substr_replace() be used effectively in PHP for string manipulation?

substr_replace() can be used effectively in PHP for string manipulation by replacing a portion of a string with another substring. This function allows you to specify the start position, length of the portion to be replaced, and the replacement string. This can be useful for tasks like masking sensitive information, modifying specific parts of a string, or performing complex text transformations.

// Example of using substr_replace() to mask sensitive information
$string = "1234-5678-9012-3456";
$maskedString = substr_replace($string, "****", 0, 12);
echo $maskedString; // Output: ****-3456