str_replace Function in PHP

What is str_replace Function?


In PHP, this function is used to replace all occurrences of the search string with the replacement string, this function is case sensitive.



In the above syntax "search" specifies the value to be replaced,"replace" specifies the value to be replaced with, "string" specifies the string to be searched in, "count" specifies the variable with the number of replacements.

Example :

echo str_replace("India","Folks","Hiox India");
Result :

Hiox Folks

In the above example "Hiox India", "India" is replaced with "Folks",since the function is case sensitive the strings are in matching case.

PHP Topics

Ask Questions

Ask Question