str_replace()
functionYou can use the PHP str_replace()
function to replace all the occurrences of a word within a string.
In the following example, the word "facts" is replaced by the word "truth".
<?php
$my_str = 'If the facts do not fit the theory, change the facts.';
// Display replaced string
echo str_replace("facts", "truth", $my_str);
?>
I hope you like this small article.
Hi, My name is Harsukh Makwana. i have been work with many programming language like php, python, javascript, node, react, anguler, etc.. since last 5 year. if you have any issue or want me hire then contact me on [email protected]
How to get all the keys of an associative array in PHP
Use the PHP array_keys() funct...How to run Python 3 Script in Laravel 7?
Hi, Artisan In this article i will sh...How to split a string into an array in PHP
Use the PHP explode() function...How to add or remove rows inside a table dynamically using jQuery
Use the jQuery .append() or .remove() Me...How to get substring from a string using jQuery
Use the JavaScript substring() ...