【发布时间】:2013-12-30 14:02:50
【问题描述】:
我正在使用脚本从 ftp 备份文件。代码如下。
include "recurseZip.php";
//Source file or directory to be compressed.
$src='source/images/black.png';
//Destination folder where we create Zip file.
$dst='backup';
$z=new recurseZip();
echo $z->compress($src,$dst);
现在我想从包含文件名列表的 source/files.txt 中获取 $src 的值。
我的 .txt 文件:
index.php.bk-2013-12-02
index.php.bk-2013-12-07
index.php.bk-2013-12-10
index.php.bk-2013-12-20
index.php.bk-2013-12-26
function.php.bk-2013-12-20
function.php.bk-2013-12-23
contact.php.bk-2013-12-23
contact.php.bk-2013-12-30
我的 source/files.txt 包含 10 个文件名,这些文件名需要作为值分配给变量 $src 我正在使用此脚本 http://ramui.com/articles/php-zip-files-and-directory.html
我该怎么做?
任何帮助将不胜感激。
谢谢。
【问题讨论】:
-
“从source/files.txt获取文件名到$src”是什么意思
-
你想只获取文件名,即 black.png 并将其分配给 $src 变量吗?
-
你想读取一个名为 files.txt 的文件并根据它的内容给 $src 命名吗??
-
嗨 Starr,我已经在下面给出了答案。看看吧。
-
大家好.. 感谢您的快速回复。我认为我的问题不够清楚。我的 source/files.txt 包含 10 个文件名,这些文件名需要作为值分配给变量 $src 我正在使用这个脚本 link
标签: php variables text-files filenames