PHP substr_replace Function

What is substr_replace Function?

Explanation

In PHP, this function is used to replace text within a portion of a string.

Syntax:




substr_replace(string,replacement,start,length)



In the above syntax given "string" is the input to check, "replacement" specifies the string to insert,
"start" specifies where to start replacing, "length" specifies how many characters to replace.

Example :




<?php
echo substr_replace("Hi sam","ram",3);
?>


Result :


Hi ram

PHP Topics


Ask Questions

Ask Question