Note that there are some explanatory texts on larger screens.

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

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload