Reputation: 1
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; ?> </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)).
Upvotes: 0
Views: 129
Reputation: 12078
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
Upvotes: 0
Reputation: 3364
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).
Upvotes: 1