从文件中读取行并输出作为下拉列表的选项
我有 $data 包含类似这样的内容并且经常更改:
backup 2011-04-15 16:39:18.559965.zip
backup 2011-04-15 16:39:56.289656.zip
backup 2011-04-15 16:41:34.463754.zip
backup 2011-04-15 16:41:54.089134.zip
backup 2011-04-15 16:42:18.742616.zip
backup 2011-04-16 13:12:33.083622.zip
backup 2011-04-16 13:14:53.387308.zip
backup 2011-04-17 00:30:32.591461.zip
我怎样才能将其转换为下拉列表,以便人们可以从中进行选择,并且我可以将结果用作 $_POST['file']?
I have $data which contains something like this and changes often:
backup 2011-04-15 16:39:18.559965.zip
backup 2011-04-15 16:39:56.289656.zip
backup 2011-04-15 16:41:34.463754.zip
backup 2011-04-15 16:41:54.089134.zip
backup 2011-04-15 16:42:18.742616.zip
backup 2011-04-16 13:12:33.083622.zip
backup 2011-04-16 13:14:53.387308.zip
backup 2011-04-17 00:30:32.591461.zip
How can i make that it will transform it into a Dropdown list, so people can choose from and i can use result as $_POST['file']?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
>
编辑
我没有提供任何代码,因为您应该能够按照上述步骤自己编写代码。只需使用 Google 即可了解这些功能的工作原理。你只能通过自己实现一些东西来学习 PHP。不要指望人们为你编写完整的脚本。
无论如何,这应该可以工作:)
您也可以使用 file_get_contents() 而不是 fopen()。
编辑
添加了file(),如Wiseguy推荐的
EDIT
I did not provide any code because you should be able to write this yourself following the steps above. Simply use Google to find out how these functions work. You can only learn PHP by implementing things yourself. Don't expect people to write complete scripts for you.
Anyways, this should be working :)
You can also use file_get_contents() instead of fopen().
EDIT
Added file() like recommended by Wiseguy