-1
ローカルファイルから最初の200文字を読みたいのですが、私のコードはテキストファイルのすべての内容を読み込んでいます。phpでテキスト長 'file_get_contents'を制限し、 'Read more'リンクを提供する方法
<?php
$connection= new mysqli($DB_host,$DB_user,$DB_pass,$DB_name);
$query = mysqli_query($connection,"SELECT * FROM new_record ORDER BY id");
while ($row = mysqli_fetch_array($query)) {
$fileName = $row['name'];
$fileContents = file_get_contents("txt/$fileName");
echo ("$fileContents");
}
?>
あなたは試してみることができます:echo substr($ fileContens、0,200); –