Inserting code into a text file or deleting unwanted code?

I have some code I have grabbed from a news site. I need to take that code and either:

1- Delete the unwanted HTML from around the headlines I have grabbed or
2- Add beginning and ending tags to the code so I can grab it again and just display what is between the two tags I just inserted.

All I need to know is how to either insert code into a text file via PHP, or how to delete unwanted lines of code. Any help or direction to where I can find help would be greatly appreciated.
BiceAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

girish_nairCommented:
Hi,

try these:-
1) read the file into a variable(either string [fread] or array [file])
2) parse through the contents of this variable and grab the required thing (useing string functions)
OR replace the unwanted content with blank (use eregi_replace("pattern","",$variable)
3) now write the new content to the file

Cheers,
Girish
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
BiceAuthor Commented:
Thanks, I will look into this and hopefully get it to work. I just needed a direction to go towards.
0
girish_nairCommented:
:)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.