$dataArray = array();
//Number of chars for the string
$num = 200;
//Check if DIR exists
if ($handle = opendir('.')) {
//Loop over the directory
while (false !== ($file = readdir($handle))) {
//Strip out the . and .. files
if ($file != "." && $entry != "..") {
$dataArray[] = array();
//Store file contents
$filecontent = file_get_contents($file);
//Split the content and store in array
$length = strlen($filecontent);
$dataArray[] = array(substr($filecontent, 0, $num), substr($filecontent, $num, $length));
}
}
//close the dir
closedir($handle);
}
При этом вы получите массив со всем содержанием ваших .txt файлов, splittet на 2 строку, один с 200 символами другой с остальным.
Строка длиной 200 бит является $ dataArray [x] [0], а другая - $ dataArray [x] [1].
Теперь вы можете использовать это в HTML:
<?php foreach($dataArray as $data) { ?>
<div class="visible">
<?php echo $data[0]; ?>
</div>
<div class="hidden">
<?php echo $data[1]; ?>
</div>
<?php } ?>
https://www.google.com/search?q=php+reading+text+file – undefined
Что вопрос/проблема? – KingCrunch