Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 221
  • Last Modified:

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.
0
Bice
Asked:
Bice
  • 2
1 Solution
 
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
 
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

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now