0

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)).

2 Answers 2

1

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).

Sign up to request clarification or add additional context in comments.

1 Comment

It's a second one. I'll look into SimpleXML ... Thanks!
0

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

1 Comment

You can use the same features as said in Vim which has a windows version.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.