开发者

PHP data split into tables

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 开发者_Python百科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);
?> 


Assuming each line is in the variable $line:

list($url, $path) = explode(',', $line);
//now use $url and $path to your heart's content

So if the line was:

http://www.books.com/imgs/b0388.jpg , ../../mdia/imp/books/b0388.jpg

So therefore it would become (after the above code):

$url == "http://www.books.com/imgs/b0388.jpg "
$path == "../../mdia/imp/books/b0388.jpg"
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜