Here is my code that generates random texts from the random.txt
file inside a input field.
<?php
//Path of file
$myFile = "random.txt";
//Read file from array
$lines = file($myFile);
//Get number line of file
$lineTotal = count($lines);
//Remove 1 line (start from 0)
$count = $lineTotal-1;
//Get casual number
$number_casual = rand(0,$count);
//Print line 2 ([0] = 1 ; [1] = 2 ; ...)
?>
<input name="accesspin" style="width: 300px" value="<?php echo htmlentities( $lines[$number_casual] ); ?>" size="36">
Here is the random.txt
file:
USA
UK
Canada
I want to show random pictures above the input field:
<img src="A random pic"alt="Flags" height="42"width="42">
<input name="accesspin" style="width: 300px" value="<?php echo htmlentities( $lines[$number_casual] ); ?>" size="36">
And the random.txt will look like this:
us_flag.jpg
USA
uk_flag.jpg
UK
ca_flag.jpg
Canada
I want this PHP code to randomly show a flag picture above the input field and the country name under the flag picture's file name in the txt file to show inside the input field.
Aucun commentaire:
Enregistrer un commentaire