Skip to content

Instantly share code, notes, and snippets.

@masalib masalib/test.php
Created Apr 2, 2019

Embed
What would you like to do?
phpで、長文を「。」区切りでフラッシュ表示させるプログラム
<html>
<head>
<title>phpでlist.txt読み込むという制限がめんどくさい</title>
<script language="JavaScript">
count = 0;
function setTextLine()
{
str = new Array();
<?php
// 入力ファイルパス
$inputpath = 'list.txt';
// ファイルの内容をすべて取得する
$datas = file_get_contents($inputpath);
$arr_data = explode("",$datas);
$i = 0;
foreach($arr_data as $strdata){
echo "str[" . $i ."] = `" . nl2br($strdata) ."`;\n";
$i++;
}
?>
if (count >= str.length) return;
txt = "";
count++;
for (i=0; i<count; i++) txt = str[i];
document.all["outText"].innerHTML = txt;
setTimeout("setTextLine()",1000);
}
</script>
</head>
<body>
<input type="button" value="出力開始" onclick="setTextLine();" />
<div id="outText" >初期</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.