What is the use of str_replace() PHP String function?
str_replace() searches a string for some text and replaces it with new text. It replaces all matches.
<?php
echo str_replace("Hello", "Hi", "Hello World, Hello PHP");
?>
Output:
Tutorials Class - Output Window
Hi World, Hi PHP
It is case-sensitive. For a case-insensitive replace use str_ireplace(). See more examples in how to replace a part of a string in PHP.
Learn more about the similar topics:
| Tutorials |
|---|
| No Content Found. |
| Exercises & Assignments |
|---|
| No Content Found. |
| Interview Questions & Answers |
|---|
| No Content Found. |