<bdo id='f60sv'></bdo><ul id='f60sv'></ul>
    1. <tfoot id='f60sv'></tfoot>
    2. <small id='f60sv'></small><noframes id='f60sv'>

      <i id='f60sv'><tr id='f60sv'><dt id='f60sv'><q id='f60sv'><span id='f60sv'><b id='f60sv'><form id='f60sv'><ins id='f60sv'></ins><ul id='f60sv'></ul><sub id='f60sv'></sub></form><legend id='f60sv'></legend><bdo id='f60sv'><pre id='f60sv'><center id='f60sv'></center></pre></bdo></b><th id='f60sv'></th></span></q></dt></tr></i><div id='f60sv'><tfoot id='f60sv'></tfoot><dl id='f60sv'><fieldset id='f60sv'></fieldset></dl></div>
    3. <legend id='f60sv'><style id='f60sv'><dir id='f60sv'><q id='f60sv'></q></dir></style></legend>

        如何在php中获取目录中的最新文件

        How to get the newest file in a directory in php(如何在php中获取目录中的最新文件)
        1. <tfoot id='XTyJR'></tfoot>

            <legend id='XTyJR'><style id='XTyJR'><dir id='XTyJR'><q id='XTyJR'></q></dir></style></legend>
              • <bdo id='XTyJR'></bdo><ul id='XTyJR'></ul>

                <small id='XTyJR'></small><noframes id='XTyJR'>

                  <i id='XTyJR'><tr id='XTyJR'><dt id='XTyJR'><q id='XTyJR'><span id='XTyJR'><b id='XTyJR'><form id='XTyJR'><ins id='XTyJR'></ins><ul id='XTyJR'></ul><sub id='XTyJR'></sub></form><legend id='XTyJR'></legend><bdo id='XTyJR'><pre id='XTyJR'><center id='XTyJR'></center></pre></bdo></b><th id='XTyJR'></th></span></q></dt></tr></i><div id='XTyJR'><tfoot id='XTyJR'></tfoot><dl id='XTyJR'><fieldset id='XTyJR'></fieldset></dl></div>
                    <tbody id='XTyJR'></tbody>
                  本文介绍了如何在php中获取目录中的最新文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  所以我有这个处理 CSV 文件的应用程序.我有一行代码来加载文件.

                  So I have this app that processes CSV files. I have a line of code to load the file.

                  $myFile = "data/FrontlineSMS_Message_Export_20120721.csv";  //The name of the CSV file
                  $fh = fopen($myFile, 'r');                             //Open the file
                  

                  我想找到一种方法来查看 data 目录并获取最新的文件(它们都有日期标签,因此它们在 data) 并将名称设置为等于 $myFile.

                  I would like to find a way in which I could look in the data directory and get the newest file (they all have date tags so they would be in order inside of data) and set the name equal to $myFile.

                  我真的找不到和理解 php 目录的文档,所以任何有用的资源也将不胜感激.谢谢.

                  I really couldn't find and understand the documentation of php directories so any helpful resources would be appreciated as well. Thank you.

                  推荐答案

                  这是使用 scandir 的尝试,假设目录中仅有的文件具有带时间戳的文件名:

                  Here's an attempt using scandir, assuming the only files in the directory have timestamped filenames:

                  $files = scandir('data', SCANDIR_SORT_DESCENDING);
                  $newest_file = $files[0];
                  

                  我们首先按降序列出目录中的所有文件,然后,该列表中的第一个文件具有最大"文件名——因此具有最大的时间戳值——因此是最新的.

                  We first list all files in the directory in descending order, then, whichever one is first in that list has the "greatest" filename — and therefore the greatest timestamp value — and is therefore the newest.

                  请注意,scandir 是在 PHP 5 中添加的,但 其文档页面 显示了如何在 PHP 4 中实现该行为.

                  Note that scandir was added in PHP 5, but its documentation page shows how to implement that behavior in PHP 4.

                  这篇关于如何在php中获取目录中的最新文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                  PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                  mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                  Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                  Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                  Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)
                    <legend id='KAxlz'><style id='KAxlz'><dir id='KAxlz'><q id='KAxlz'></q></dir></style></legend>

                        • <i id='KAxlz'><tr id='KAxlz'><dt id='KAxlz'><q id='KAxlz'><span id='KAxlz'><b id='KAxlz'><form id='KAxlz'><ins id='KAxlz'></ins><ul id='KAxlz'></ul><sub id='KAxlz'></sub></form><legend id='KAxlz'></legend><bdo id='KAxlz'><pre id='KAxlz'><center id='KAxlz'></center></pre></bdo></b><th id='KAxlz'></th></span></q></dt></tr></i><div id='KAxlz'><tfoot id='KAxlz'></tfoot><dl id='KAxlz'><fieldset id='KAxlz'></fieldset></dl></div>
                            <bdo id='KAxlz'></bdo><ul id='KAxlz'></ul>
                              <tbody id='KAxlz'></tbody>

                            <small id='KAxlz'></small><noframes id='KAxlz'>

                            <tfoot id='KAxlz'></tfoot>