Syntax of str_replace() function and Usage
str_replace(search,replace,subject,count)
search -> Search for Specifies the value.
replace -> The replacement value that replaces found search values.
subject ->The string being searched and replaced on.
count ->Optional. A variable that counts the number of replacements.
1.Create str_replace()
str_replace("car","bike","I like car")
echo str_replace("car","bike","I like car")
<?php
echo str_replace("car","bike","I like car");
?>
Complete Code of str_replace() Function:
<!DOCTYPE html>
<html lang="en">
<head>
<title>PHP string replace function</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
</head>
<body>
<div class="container">
<div class="text-center">
<h1>PHP str_replace() Function</h1>
</div>
<br>
<h2>The str_replace() function replace all the occurrences of the search string.</h2>
<div class="well">
<?php
echo "<h4>".str_replace("car","bike","I like car")."</h4>";
?>
</div>
<br>
</div>
</body>
</html>