Jump to content

PHP/Mysql question


eric2453

Recommended Posts

I have a mailing list archived in a bunch of files. Each file is in the following format:

 

[some HTML at beginning]

-----------------------

[first message]

-----------------------

[second message]

...

-----------------------

[last message]

-----------------------

[some HTML at end]

 

I want to take all these files and import each message (=the text between "--------"'s) into a MySql entry. Can anyone give me hints as to do this? Should I use PHP or Perl or something else? I am a total beginner with these languages. Anyone just want to write the script for me? It doesn't look hard :-)

 

Thanks!

Link to comment
https://forums.phpfreaks.com/topic/99169-phpmysql-question/
Share on other sites

You need to find a pattern in the files to work with.

 

 

If you literally have "-----------" between each message you can use that as a delimiter between each message in the file.

 

You might want to read up on regular expressions as you can use the preg functions in PHP to search, match, replace text using regular expressions. Check the PHP manual under Function Reference for this. (Note: I have made reference to preg which is the Perl regular expression functions. I think there are more REGEXP function in PHP, I just use the Perl compatible ones because that's where I first learnt REGEXP.)

 

If you can work out how to use regular expression functions then doing what you asked will become a piece of pie and you might find regular expressions rather addictive ;)

Link to comment
https://forums.phpfreaks.com/topic/99169-phpmysql-question/#findComment-507344
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.