PHP str_replace

General discussions related to php

Moderators: egami, macek, gesf

Post Reply
NigelRen
php-forum Fan User
php-forum Fan User
Posts: 622
Joined: Fri Aug 05, 2011 9:53 am

Sun Aug 19, 2012 12:09 am

The simplest way of doing this is having a variable with the previous value in it. So if your working with $word then $prevWord would be the previous version of it. Before making any change to $word - simply use $prevWord = $word;. Then each change would actually be something like...

Code: Select all

$word=str_replace("a","o",$prevWord);

Acesystech
New php-forum User
New php-forum User
Posts: 35
Joined: Mon Aug 20, 2012 10:27 pm
Location: Ernakulam
Contact:

Mon Aug 20, 2012 11:39 pm

The str_replace() function replaces some characters with some other characters in a string.

Syntax:

str_replace(find,replace,string,count)

Where,

find:-Required. Specifies the value to find
replace:- Required. Specifies the value to replace the value in find
string:-Required. Specifies the string to be searched
count:-Optional. A variable that counts the number of replacements

Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 1 guest