Okey.
Well.. as long as the only place you have \n\n is between each section then it should be pretty easy to do.. I think.
The first thing that I would do if I was trying to do the same thing would be to load the entire text file into a variable named $thefile.
Then once you have it use the explode() function to split that variable into chunks like this... $chunks=explode("\n\n",$thefile);
Now you will have an array called $chunks which contains each section.
From here you could do some like this..
Code: Select all
<?php
$number_of_chunks=count($chunks); //get the number of chunks
$loop=0;
while($loop<=$number_of_chunks)
{
$tinychunk=explode("\n",$chunks[$loop]);
$tinychunk[0]=str_replace("File:","",$tinychunk[0]);
$tinychunk[1]=str_replace("Length:","",$tinychunk[1]);
$tinychunk[2]=str_replace("UUHash:","",$tinychunk[2]);
mysql_query("INSERT INTO `your_table` (`file`,`length`,`uuhash`) VALUES ('$tinychunk[0]','$tinychunk[1]','$tinychunk[2]')";
$loop++;
}
?>
If everything works it should split up your file into bits and then add each bit into your database as you want.
You will obviously need to add your database connection code in their.. and you may need to tweek the code a bit but it should give you a rough idea of what to do.
Hope this helps.