PHP 数据拆分成表
我有如下所示的文本文件:
http://www.books.com/imgs/b0388.jpg , ../../mdia/imp/books/b0388.jpg
http://www.books.com/imgs/b0369.jpg , ../../mdia/imp/books/b0369.jpg
http://www.books.com/imgs/b0309.jpg , ../../mdia/imp/books/b0309.jpg
现在我需要将 url 和路径与表列分开,当然要删除逗号(我希望它们位于不同的表列中)。之后,我必须将按钮和表单放在一些右列中。我的代码如下:
<?php
$filename="listing.txt";
$fp=fopen($filename,'r');
if ($fp == FALSE){
echo "File not opened";
return 0;}
//Default product name before administrator's modifications
$default="Product";
while ( ! feof( $fp ) ) {
$line = fgets( $fp, 1024 );
echo $line;
echo $default;
echo "<input type='text'></input>";
echo "<button type='button'>Name product</button>";
echo "<br/>";
}
fclose($fp);
?>
I have text file which looks like this:
http://www.books.com/imgs/b0388.jpg , ../../mdia/imp/books/b0388.jpg
http://www.books.com/imgs/b0369.jpg , ../../mdia/imp/books/b0369.jpg
http://www.books.com/imgs/b0309.jpg , ../../mdia/imp/books/b0309.jpg
Now I need to separate the url and the path with table columns with removing the comas of course (I want them in different table columns). After that I had to put buttons and forms at some right columns. My code is as follows:
<?php
$filename="listing.txt";
$fp=fopen($filename,'r');
if ($fp == FALSE){
echo "File not opened";
return 0;}
//Default product name before administrator's modifications
$default="Product";
while ( ! feof( $fp ) ) {
$line = fgets( $fp, 1024 );
echo $line;
echo $default;
echo "<input type='text'></input>";
echo "<button type='button'>Name product</button>";
echo "<br/>";
}
fclose($fp);
?>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
假设每一行都在变量
$line
中:所以如果该行是:
因此它会变成(在上面的代码之后):
Assuming each line is in the variable
$line
:So if the line was:
So therefore it would become (after the above code):