🌐
W3Schools
w3schools.com › php › func_string_str_replace.asp
PHP str_replace() Function
If find is an array and replace is a string, the replace string will be used for every find value · Note: This function is case-sensitive. Use the str_ireplace() function to perform a case-insensitive search. Note: This function is binary-safe. ... <?php $arr = array("blue","red","green","yellow"); print_r(str_replace("red","pink",$arr,$i)); echo "Replacements: $i"; ?> Try it Yourself »
🌐
W3Schools
www-db.deis.unibo.it › courses › TW › DOCS › w3schools › php › func_string_str_replace.asp.html
PHP str_replace() Function
If find is an array and replace is a string, the replace string will be used for every find value · Note: This function is case-sensitive. Use the str_ireplace() function to perform a case-insensitive search. Note: This function is binary-safe. ... <?php $arr = array("blue","red","green","yellow"); print_r(str_replace("red","pink",$arr,$i)); echo "Replacements: $i"; ?> Run example »
🌐
PHP
php.net › manual › en › function.str-replace.php
PHP: str_replace - Manual
If search and replace are arrays, then str_replace() takes a value from each array and uses them to search and replace on subject. If replace has fewer values than search, then an empty string is used for the rest of replacement values.
🌐
W3Schools
w3schools.com › Php › func_string_str_ireplace.asp
PHP str_ireplace() Function
Use the str_replace() function to perform a case-sensitive search. Note: This function is binary-safe. ... <?php $arr = array("blue","red","green","yellow"); print_r(str_ireplace("RED","pink",$arr,$i)); // This function is case-insensitive echo "Replacements: $i"; ?> Try it Yourself »
🌐
W3Schools
w3schools.sinsixx.com › php › func_string_str_replace.asp.htm
PHP str_replace() Function - SinSiXX - W3Schools
Free HTML XHTML CSS JavaScript DHTML XML DOM XSL XSLT RSS AJAX ASP ADO PHP SQL tutorials, references, examples for web building.
🌐
W3Schools
w3schools.com › php › phptryit.asp
W3Schools online PHP editor
Search the string "Hello World!", find the value "world" and replace it with "Peter": Hello Peter!
🌐
Cach3
w3schools.com.cach3.com › php › func_string_str_replace.asp.html
PHP str_replace() Function
If find is an array and replace is a string, the replace string will be used for every find value · Note: This function is case-sensitive. Use the str_ireplace() function to perform a case-insensitive search. Note: This function is binary-safe. ... <?php $arr = array("blue","red","green","yellow"); print_r(str_replace("red","pink",$arr,$i)); echo "Replacements: $i"; ?> Try it Yourself »
🌐
W3Schools
w3schools.invisionzone.com › server scripting › php
str_replace - PHP - W3Schools Forum
August 27, 2012 - Hi people. I need help. I want to use str_replace function a few times. THe problem is this: for example i have two words: "table" and "house".I want to replace one word's letters by other one, like: housetousetausetabsetable I have letters, when I click on "t", "house"-becomes "touse". But when ...
🌐
W3Schools
w3schools.com › php › func_string_substr_replace.asp
PHP substr_replace() Function
<?php $replace = array("1: AAA","2: AAA","3: AAA"); echo implode("<br>",substr_replace($replace,'BBB',3,3)); ?> Try it Yourself » · ❮ PHP String Reference · ★ +1 · Sign in to track progress · REMOVE ADS · New · Coding fundamentals as a game. Bite-sized lessons and challenges. Learn more » · Ready to start your journey? Your streak is waiting. +60 XP · PLUS · SPACES · GET CERTIFIED · FOR TEACHERS · PRACTICE · CONTACT US · × · If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail: sales@w3schools.com ·
Find elsewhere
🌐
W3Schools
w3schools.com › php › php_string_modify.asp
PHP - Modify Strings
... The strtoupper() function returns a string in upper case. ... The strtolower() function returns a string in lower case. ... The str_replace() function replaces some characters with some other characters in a string.
🌐
PHP Tutorial
phptutorial.net › home › php tutorial › php str_replace
PHP str_replace - PHP Tutorial
April 7, 2025 - This tutorial shows you how to use PHP str_replace() function to return a new string with all occurrences of a substring replaced with another string.
🌐
W3Schools
w3schools.com › php › func_regex_preg_replace.asp
PHP preg_replace() Function
<?php $str = 'Visit Microsoft!'; $pattern = '/microsoft/i'; echo preg_replace($pattern, 'W3Schools', $str); ?> Try it Yourself »
🌐
GeeksforGeeks
geeksforgeeks.org › php › php-str_replace-function
PHP str_replace() Function - GeeksforGeeks
November 30, 2021 - The str_replace() is a built-in function in PHP and is used to replace all the occurrences of the search string or array of search strings by replacement string or array of replacement strings in the given string or array respectively.
🌐
Codecademy
codecademy.com › docs › php › string functions › str_replace()
PHP | String Functions | str_replace() | Codecademy
July 28, 2023 - The str_replace() function returns a string with occurrences of a specified substring replaced by another string.
🌐
Benjamin Crozat
benjamincrozat.com › home › blog › php str_replace(): examples, gotchas, and alternatives
PHP str_replace(): examples, gotchas, and alternatives
1 month ago - $message = 'Hello, unknown person!'; echo str_replace('unknown person', 'Benjamin', $message); // Hello, Benjamin! PHP replaces all matching occurrences, not just the first one.