473,387 Members | 1,749 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Mass/dynamic find & replace

I'm scratching my head slightly about how to do the following. I have
roughly 800 PHP includes in as many directores, 2 levels deep. Inside each
include I have the same 2 variables, but with different values:

$title = "This is the Title";
$alt = "This is the another Title";

Obiously, the values are different in each include, but the layout is the
same. What I would like to do is replace the above in each file with this:

$title = "This is the Title";
$titlecopy = "This is the Title";
$alt = "This is the another Title";

So basically I want the $title variable duplicating on the line below,
keeping the same value, but renaming itself to $titlecopy. I could explain
why I need to do this, but it's a long story...

I'm not even sure if I need to be using PHP to do this? or some text program
that will allow me to do it? either client or server side?

many thanks for any help.

Jul 17 '05 #1
2 2145

"mark" <ma********@nospammail.com> wrote in message
news:cc**********@newsg4.svr.pol.co.uk...
I'm scratching my head slightly about how to do the following. I have
roughly 800 PHP includes in as many directores, 2 levels deep. Inside each
include I have the same 2 variables, but with different values:

$title = "This is the Title";
$alt = "This is the another Title";

Obiously, the values are different in each include, but the layout is the
same. What I would like to do is replace the above in each file with this:

$title = "This is the Title";
$titlecopy = "This is the Title";
$alt = "This is the another Title";

So basically I want the $title variable duplicating on the line below,
keeping the same value, but renaming itself to $titlecopy. I could explain
why I need to do this, but it's a long story...

I'm not even sure if I need to be using PHP to do this? or some text program that will allow me to do it? either client or server side?

many thanks for any help.


Sounds like a fun half hour script for you to make - "opendir",
"preg_replace", fantastic. I've got a Python one somewhere that did this
with exclusion dictionaries for when we had to convert say, char* to LPSTR
(don't ask - oh, ok, Unicode) in a million lines of code in a complex tree.
If you're still fighting tonight I'll give it here even though it's WAY off
topic, being Python and all.

Garp
Jul 17 '05 #2

"mark" <ma********@nospammail.com> wrote in message
news:cc**********@newsg4.svr.pol.co.uk...
I'm scratching my head slightly about how to do the following. I have
roughly 800 PHP includes in as many directores, 2 levels deep. Inside each
include I have the same 2 variables, but with different values:

$title = "This is the Title";
$alt = "This is the another Title";

Obiously, the values are different in each include, but the layout is the
same. What I would like to do is replace the above in each file with this:

$title = "This is the Title";
$titlecopy = "This is the Title";
$alt = "This is the another Title";

So basically I want the $title variable duplicating on the line below,
keeping the same value, but renaming itself to $titlecopy. I could explain
why I need to do this, but it's a long story...

I'm not even sure if I need to be using PHP to do this? or some text program that will allow me to do it? either client or server side?

many thanks for any help.


First of all there are specific find/replace tools available online
(google), some of which are free. (windows, and probably other)
If you are familiar with Linux and have your scripts on a Linux machine you
could uses gawk for this purpose. See a gawk manual online for details or
check man pages.
HTH
Pjotr
Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Xah Lee | last post by:
suppose you want to do find & replace of string of all files in a directory. here's the code: ©# -*- coding: utf-8 -*- ©# Python © ©import os,sys © ©mydir= '/Users/t/web'
2
by: Joe Kelsey | last post by:
I want to create dynamic content and use replaceChild to switch out different subtrees. I start with a span placeholder: <span id="replaceMe"></span> Then I use document.getElementById...
5
by: Manu | last post by:
Hello, i ve a little problem for validate my web site because i ve a dynamic image. And the w3c platform test don't like my image :( il someone have a idea for this problem i've just a img...
5
by: AdamM | last post by:
Hi all, Throughout my code, I have lines like this: Console.WriteLine("This is a sample with three variables: " + a + " and " + b + " and " + c); Are there any VS2005 IDE plugins or utilities...
7
by: Mike Livenspargar | last post by:
We have an application converted from v1.1 Framework to v2.0. The executable references a class library which in turn has a web reference. The web reference 'URL Behavior' is set to dynamic. We...
0
by: ApexData | last post by:
I Want Access FIND&REPLACE to stay in FIND mode. Can I place the (Access FIND&REPLACE Dialog) in a popup/modal dialog form? I need to control this process to prevent the user from pressing keys...
2
by: john | last post by:
In a table I have text field A. I would like to replace all the null values in field A to a real value, let's say 'Test'. When I use Find & Replace and I search for 'is null' and I press replace or...
7
by: John Nagle | last post by:
I've been parsing existing HTML with BeautifulSoup, and occasionally hit content which has something like "Design & Advertising", that is, an "&" instead of an "&amp;". Is there some way I can get...
7
by: Jo | last post by:
Hi, How can i differentiate between static and dynamic allocated objects? For example: void SomeFunction1() { CObject *objectp = new CObject; CObject object;
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.