By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,831 Members | 2,237 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,831 IT Pros & Developers. It's quick & easy.

Mass/dynamic find & replace

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a

"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

P: n/a

"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 discussion thread is closed

Replies have been disabled for this discussion.