Replace Parts Of A PHP String Replacing Words Characters
replace parts of a php string replacing words characters
replace, parts, of, a, php, string, replacing, words, characters
Replace Parts Of A PHP String Replacing Words Characters
Post Description: replace parts of a php string replacing words characters
POST# 414
Posted On: Fri Feb 29, 2008 12:01 pm
web hosting
Topic: Replace Parts Of A PHP String Replacing Words Characters
if you ever wanted to know how to change a character in a string, its easy with php.

lets say i have a string, the this is the value:

$string = "Wallpaperama has many screensavers you can download for free in our screensavers page"

ok, lets say i want to change all the words "screensavers" to "wallpapers" and this is how i would do it:

<?
$string = "Wallpaperama has many screensavers you can download for free in our screensavers page"
echo str_replace(('screensavers','wallpapers',$string);
?>


with this code, i am telling php that i want to replace any part of the string that contains "screensavers" and replace it with "wallpapaers" and the ouput will be like this

Wallpaperama has many wallpapers you can download for free in our wallpapers page

this is the format to use this function:

str_replace ('find this', 'replace it with this', 'in this')




Wed Mar 12, 2008 3:40 am
1
AYUSHDEEPSINGH
Reply #1005
thanks peoples i am very happy

What do you think?

* name:  

* email:  

* Please enter comments:


Receive Replies on my Comments
(An email will be sent to you when someone replies to your comments)

Add image to comments
yes no             upload