How to demonstrate the regular expression to replace the substring within the string in PHP | PHP program
Jun 24, 2021
PHP,
385 Views
How to demonstrate the regular expression to replace the substring within the string in PHP | PHP program
How to demonstrate the regular expression to replace the substring within the string in PHP | PHP program
We will demonstrate the regular expression to replace a specified substring within the string using the preg_replace() function.
<?php
$str = "Welcome to India";
$pattern = "/india/i";
$str1 = preg_replace($pattern, "USA", $str);
print ($str1);
?>