小编Kha*_*nem的帖子

修改字符串中的4位数字并插入冒号

我有一个字符串,我想修改所有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);

但是不确定如何在预浸料中再次传递相同的值吗?

php string digits colon

5
推荐指数
1
解决办法
66
查看次数

Laravel ZIP 目录和子目录

我有这段代码,但它只压缩文件,是否也可以包含其中的所有目录和文件?压缩文件应与包含以下内容的文件夹结构匹配:(就像在 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)

php directory zip laravel

3
推荐指数
1
解决办法
6505
查看次数

标签 统计

php ×2

colon ×1

digits ×1

directory ×1

laravel ×1

string ×1

zip ×1