tags:

views:

27

answers:

2

I need a function/class/or some kind of sophisticated find/ replace solution for this problem

Have a huge form with lot of:

1: input tags like this one

 <input id="Id" name="Id" class="element text large" value="" type="text" />

which needs to be "changed/replaced" to this one

<div class="element text large" id="username"><?php echo $username_var; ?>&nbsp;</div>

(NOTE: input tag has more elements than DIV tag EG(value, type,name ))

2: also labels to div

<label class="description" for="username"><?php echo $username; ?></label>

to

<div class="description"><?php echo $username; ?></div>

(NOTE: label tag has one more elements than DIV tag Eg(for)).

Any help is greatly appreciated

A: 

It's not clear from your question whether this is a purely textual replacement (in which case preg_replace is your friend) or needs to perform some kind of parsing. If the latter, have a look at SimpleXML (though there are probably smaller parsers which would do the job).

Colin Fine
It's a second one. I'll look into SimpleXML ...Thanks!
Kide
A: 

If you are on a linux box have a look at sed. It can do a find and replace very easily.

http://www.gnu.org/software/sed/ http://www.grymoire.com/Unix/Sed.html

Chris
Unfortunately i"m on Windows box..
Kide
You can use the same features as said in Vim which has a windows version.
Chris