Forum Moderators: coopster

Message Too Old, No Replies

Is this possible.

Question on replacing [#*$!] with a certain word on each page

         

BlueGhost

6:25 pm on Sep 1, 2006 (gmt 0)

10+ Year Member



Hello, i am just starting to learn programming languages and also php. I am working on a bunch of sites right now dealing with sales in different cities. I am making 200+ pages, and its becoming really annoying to have to do a find and replace to switch out each city in every page.

My question is, can i somehow let the page know that this page is the city of ORLANDO lets say, and whenever it reads [**CITY**] or something similar in the code (including paragraphs, headings and anywhere else), it automatically replaces the [**CITY**] with the city name, in the case Orlando?

I am not sure if php or anything else can do this, and i dont even know where to begin to search for something like this. Thanks!

[edited by: BlueGhost at 6:27 pm (utc) on Sep. 1, 2006]

henry0

10:43 pm on Sep 1, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



preg_replace [us2.php.net] is you friend

Here is how to:
<?
$string = "city of the rising sun";
$word = "city";
$string = preg_replace("/($word) /","orlando ",$string);
echo"$string";
?>

Respect the space where preg_replace() is used or the words will show no space in between.