Reputation: 281
This is my file data
Alex-10/9/[email protected]@@@@
What i want to do is that store every string seperated by '-' and store it into HTML textboxes:
<input type="text" name="username" value="Alex"
<input type="text" name="date of birth" value="10/9/2008" />
So far i have tried this. This 'Alex' and '10/9/2008' should be read from the upper mentioned file. I could managed to store different strings into array. But i have no idea how to put these values into different textboxes. Below, is my php code where i tried to read from a file and strode values into array
$myfile = fopen("records.txt", "r");///This is my file
while(!feof($myfile)) {
$line=fgets($myfile);
$array = explode("-",$line);
}
Upvotes: 0
Views: 21
Reputation: 8606
Your $array
must contain something like this:
Array([0]=> Alex, [1]=>10/9/2008,[2]=>male, .......)
So, username Alex is stored in $array[0]
and date of birth 10/9/2008 is stored in $array[1]
<input type="text" name="username" value="<?php echo $array[0]; ?>" />
<input type="text" name="date of birth" value="<?php echo $array[1]; ?>" />
Upvotes: 1