String Replace Function in PHP

String Replace Function in PHP. In this program, we can print the replacement within the string. The str replace() function in PHP is used to replace all occurrences of the search string or array of search strings in the given string or array with a replacement string or array of replacement strings.

<?php
echo str_replace("welcome", "welcome", "welcome to inlarn");
?>

 

Output:

welcome to inlarn

Php String Replace Function

The str replace() function in PHP is used to replace all occurrences of the search string or array of search strings in the provided string or array with the replacement string or array of replacement strings.

String in Php

A string is a grouping of characters. PHP supports a number of data types, including strings. String variables are allowed to include alphanumeric characters. Strings are formed when; you may utilise PHP Strings directly using the echo statement. A string is any sequence of characters that a script interprets literally.