我有一个字符串,我想修改所有4位数字并在两者之间插入冒号。示例:1320将变为13:20
$data = "The time is 1020 and the time is 1340 and 1550";
Run Code Online (Sandbox Code Playgroud)
我正在考虑使用 preg_match('/[0-9]{4}/', '????', $data);
但是不确定如何在预浸料中再次传递相同的值吗?
我有这段代码,但它只压缩文件,是否也可以包含其中的所有目录和文件?压缩文件应与包含以下内容的文件夹结构匹配:(就像在 PC 上压缩文件夹的正常操作一样)
- Documents
-- test.pdf
-- file.pdf
- Images
-- test.png
- mainfile.xsl
Run Code Online (Sandbox Code Playgroud)
代码如下:(取自不同的堆栈解决方案)
// Create a list of files that should be added to the archive.
$files = glob(storage_path("app/course/*.*"));
// Define the name of the archive and create a new ZipArchive instance.
$archiveFile = storage_path("app/course/files.zip");
$archive = new ZipArchive();
// Check if the archive could be created.
if ($archive->open($archiveFile, ZipArchive::CREATE | ZipArchive::OVERWRITE)) {
// Loop through all the files and add them to the archive.
foreach …Run Code Online (Sandbox Code Playgroud)