The "filetest.txt" contents is here
..................
one/yes
two/no
three/maybe
four/fun
five/ok
................
The main program is here
..........................
<?php
srand((double) microtime() * 1000000);
$readfile = file("filetest.txt");
$k=rand(0, sizeof($readfile)-2);
list($quest,$answ) = split("/",$readfile[$k]);
print("$quest<BR>$answ<br>");
?>
<button onClick="alert('Question is : <?=$quest?>')">Question1</button>
<button onclick="alert(<?php echo "'Question is : " . $quest ."'"; ?>)">Question2</button><BR>
<button onClick="alert('Answer is : <?=$answ?>')">Answer1</button>
<button onclick="alert(<?php echo "'Answer is : " . $answ ."'"; ?>)">Answer2</button>
<script>
<?php echo "var V='" . $answ ."';"; ?>
</script>
<button onclick="alert(V)">click</button>
............................................
All the above "alert" popups work with the "Question" ($quest), or first item after reading the text file.
But none of them work with the "Answer" ($answ), or the second item in text file. Why?