我已尽可能使用此代码。现在我需要一些帮助。我知道之前已经问过这个问题,但我无法弄清楚如何在我到目前为止的代码中实现它。如果文件只有三行并且我的表读了那么一切都很好。但我有一个80行的文件,我希望它提取行号21到29.任何帮助将不胜感激。目前的代码如下:
<?php
require_once 'meekrodb.php';
DB::$user = 'root';
DB::$password = '';
DB::$dbName = 'test';
// open this directory
$myDirectory = scandir('C:\xampp\htdocs\auditscripts');
// get each entry
foreach ($myDirectory as $value) {
if (is_dir($value)) {
$myDirectory = scandir('C:\xampp\htdocs\auditscripts\\' . $value);
if (is_file($value . '\secedit_local.txt'))
$dirArray[] = $value . '\secedit_local.txt';
}
}
// count elements in array
$indexCount = count($dirArray);
Print ("$indexCount files<br>\n");
// sort 'em
sort($dirArray);
// print 'em
print("<TABLE border=1 cellpadding=5 cellspacing=0 class=whitelinks>\n");
print("<TR><TH>Folder Name Name</TH><th>Item 1</th><th>Item 2</th><th>Item 3</th><th>Item 4</th><th>Item 5</th><th>Item 6</th><th>Item 7</th><th>Item 8</th><th>Item 9</th></TR>\n");
// loop through the array of files and print them all
for ($index = 0; $index < $indexCount; $index++) {
if (substr("$dirArray[$index]", 0, 1) != ".") { // don't list hidden files
$data_tisert = array();
print("<TR><TD>$dirArray[$index]</td>");
$filedata = file_get_contents($dirArray[$index]);
$l1 = explode("\n", $filedata);
foreach ($l1 as $value) {
$l1_1 = explode('=', $value);
print("<TD>$l1_1[1]</td>");
$data_tisert[] = $l1_1[1];
}
DB::insert('guest_test', array(
'GuestAccount' => $data_tisert[0],
));
print("</TR>\n");
}
}
print("</TABLE>\n");
?>