从文件中读取并存储到文本框
问题描述:
这是我的文件数据从文件中读取并存储到文本框
Alex-10/9/[email protected]@@@@
什么我想要做的是,店里的每串通过分隔“ - ”,并将其存储到HTML文本框:
<input type="text" name="username" value="Alex"
<input type="text" name="date of birth" value="10/9/2008" />
到目前为止,我已经尝试过。这个'Alex'和'10/9/2008'应该从上面提到的文件中读取。我可以设法将不同的字符串存储到数组中。但我不知道如何将这些值放入不同的文本框。下面是我的PHP代码,我试图从一个文件,大步流星值读入数组
$myfile = fopen("records.txt", "r");///This is my file
while(!feof($myfile)) {
$line=fgets($myfile);
$array = explode("-",$line);
}
答
你$array
必须包含这样的事情:
Array([0]=> Alex, [1]=>10/9/2008,[2]=>male, .......)
所以,用户名亚历克斯被存储在$array[0]
和出生日期10/9/2008存储在$array[1]
<input type="text" name="username" value="<?php echo $array[0]; ?>" />
<input type="text" name="date of birth" value="<?php echo $array[1]; ?>" />
+0
我的数组像这样: Helal10/9/[email protected] @@@@ –
+0
它的工作。谢谢您的帮助。 。 。 –
会发生什么情况?你用'$ array'做任何事情吗? – chris85