Hopefully this will be of assistance.
First off, you'll need to look into the file library associated with PHP.
Reference: http://www.php.net/manual/en/ref.filesystem.php
Using fopen and fread, you can open up the file in question and parse it from there.
<?php
// get contents of a file into a string
$filename = "something.txt";
$handle = fopen($filename, "r");
$contents = fread($handle, filesize($filename));
fclose($handle);
?>
Next, we'll use some simple string manipulation to get your important information. Using split, we can cut up your file contents into the good stuff.
Reference: http://php.net/manual/en/function.split.php
<?php
// sanitize content headers
$contents = split("<\?\?", $contents);
foreach($contents as $content) {
// remove content footers
str_replace("??>", "", $content);
}
?>
Lastly, we'll go through all the elements in the array we've just created using split and insert them into our database.
Reference: http://php.net/manual/en/book.mysql.php
<?php
// sanitize content headers
$contents = split("<\?\?", $contents);
foreach($contents as $content) {
if (empty($content)) {
continue;
}
// remove content footers
str_replace("??>", "", $content);
// insert into database
mysql_query("INSERT INTO `something` VALUES ('" . $content . "')");
}
?>
Overall, the final code should look something like this:
<?php
// get contents of a file into a string
$filename = "something.txt";
$handle = fopen($filename, "r");
$contents = fread($handle, filesize($filename));
fclose($handle);
// sanitize content headers
$contents = split("<\?\?", $contents);
foreach($contents as $content) {
if (empty($content)) {
continue;
}
// remove content footers
str_replace("??>", "", $content);
// insert into database
mysql_query("INSERT INTO `something` VALUES ('" . $content . "')");
}
?>
Good luck!