This section contains the detail about PHP str_replace function of String.
PHP str_replace function of String
The str_replace function is used to replace sub string in a string. This function replaces all the occurrence of sub string in the string.
The syntax is given below :
str_replace(sub string to be replace, sub string which replaces, original string)
Example :
Given below example give you a clear idea :
<?php //Main string in which we replace sub string $mainstring = "Welcome to devmanuals !!!. person you will get all the programming stuff!"; //string for girls $boy = str_replace("person", "Boy", $mainstring); //string for boys $girl = str_replace("person", "Girl", $mainstring); echo "Student : ". $boy . "<br />"; echo "Student : ". $girl; ?>
Output :
Student : Welcome to Devmanuals !!!. Boy you will get all the programming
stuff!
Student : Welcome to Devmanuals !!!. Girl you will get all the programming
stuff!
[ 0 ] Comments