这是我的文件数据
Alex-10/9/2008-male-123456789-jaowat@gmail.com-helal@@@@我想要做的是存储由'-‘分隔的每个字符串,并将其存储到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);
}发布于 2016-10-22 03:34:36
您的$array必须包含如下内容:
Array([0]=> Alex, [1]=>10/9/2008,[2]=>male, .......)因此,用户名Alex存储在$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]; ?>" />https://stackoverflow.com/questions/40188023
复制相似问题