Php 仅显示文本文件中的最后10行
我不是程序员,所以我不知道如何编辑它 我使用的代码是我在stackoverflow中找到的,我只想显示文本文件的最后10行Php 仅显示文本文件中的最后10行,php,javascript,ajax,file,text,Php,Javascript,Ajax,File,Text,我不是程序员,所以我不知道如何编辑它 我使用的代码是我在stackoverflow中找到的,我只想显示文本文件的最后10行 <html> <head> <script type="text/javascript"> function loadXMLDoc() { var xmlhttp; if (window.XMLHttpRequest) { xmlhttp=new XMLHttpRequest();
<html>
<head>
<script type="text/javascript">
function loadXMLDoc()
{
var xmlhttp;
if (window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","status.txt",true);
xmlhttp.send();
}
</script>
</head>
<body>
<script type="text/javascript">
loadXMLDoc();
</script>
<div id="myDiv">Current Status</div>
<script type="text/javascript">
setInterval("loadXMLDoc()", 2000);
</script>
</body>
</html>
以下是一种可能的解决方案:
... = xmlhttp.responseText.split("\n").slice(-10).join("\n");
谢谢:现在效果很好:@user1994876不客气。