• Post category:PHP

What is  str_replace function in PHP

 str_replace

Learn what is str_replace function in php is with example code. If we need to perform substitution within a string. PHP also has the str_replace() function, designed specifically to perform find-and-replace operations. This function accepts three arguments, the search term, the replacement term, and the string in which to perform the replacement. We can also replace white space. See the below Example code:

syntax:

str_replace(search, replace, stringname)

Ex:

<?php
$str = "johh@gmail.com";
echo str_replace('@', ' at ', '$str); // replace '@' with 'at'
?>

Output:
john at gmail.com

READ ALSO  What is User Defined Functions in PHP

Leave a Reply