I am using php to write a function that reads in lines from a text file and creates a form with the corresponding input values. I have a text file that looks like this:
title = Test Page
checkbox = shoe
checkbox = comb
I can separate these lines into an array, ($array[0] = title, checkbox, checkbox, and $array[1] = Test Page, shoe, comb) but I can’t seem to figure out how to get the function to print out each array with its value. For example: if my function reads the line “checkbox = shoe”, I have the statement print ("$check");, which should print a checkbox on a form with its value being shoe. While testing, I got it to do that once, but it would only print out a checkbox with shoe like a million times on the page and never stop. It never reads the next line to see what the input will be. I tried to correct this, and now I can’t even get it to print that out again. If anybody could help or show me where to get some help, it would be greatly appreciated. Here is where my code acts up:
<?php
$data = file('test_read.txt');
$line = explode("=", $data[1]);
while ($line[0] == 'checkbox'){
$check = $line[1];
print ("<input type=checkbox name=userbox value=$check>$check");
}
?>