Demonstrating the power of the preg_find() function
$files = preg_find('/./', '../code'); foreach($files as $file) printf("<br>%s\n", $file);Output:
../code/404.phps
../code/array_unique_recursive.phps
../code/dirlister.phps
../code/hexstr.phps
../code/morse.phps
../code/number_to_words.phps
../code/number_to_words_ex.phps
../code/rc4.inc.phps
../code/rc4.phps
../code/recursive_readdir.phps
../code/runtimer.phps
../code/showvalidemail.php.txt
../code/str_case.phps
../code/str_split.phps
../code/strnpos.phps
../code/tail-10.phps
../code/tail-f.phps
../code/wordwrap_bigwords.phps
../code/200501152253
../code/404.php
../code/argparse.php
../code/array_unique_recursive.php
../code/bcceil.php
../code/code_debug_timing.php
../code/days_of_year.php
../code/dirlister.php
../code/dominicsayers.php
../code/foo.php
../code/ftruncate.php
../code/hexstr.php
../code/maillog.phps
../code/morse.php
../code/number_to_words.php
../code/number_to_words_apathy.php
../code/number_to_words_ex.php
../code/parse_str_quoted.inc.php
../code/rc4.inc.php
../code/rc4.php
../code/recursive_readdir.php
../code/runtimer.php
../code/showvalidemail2.php
../code/single_astmatch.php
../code/str_case.php
../code/str_rotN.php
../code/str_split.php
../code/strnpos.php
../code/tail-10.php
../code/tail-f.php
../code/tlds-alpha-by-domain.txt
../code/validate_email.inc.phps
../code/validate_email.inc.phps.bak
../code/wordwrap_bigwords.php
../code/rc4.inc.asp
../code/showvalidemail.php
../code/showvalidemail3.php
$files = preg_find('/./', '../code', PREG_FIND_RECURSIVE); foreach($files as $file) printf("<br>%s\n", $file);Output:
../code/404.phps
../code/array_unique_recursive.phps
../code/dirlister.phps
../code/hexstr.phps
../code/morse.phps
../code/number_to_words.phps
../code/number_to_words_ex.phps
../code/rc4.inc.phps
../code/rc4.phps
../code/recursive_readdir.phps
../code/runtimer.phps
../code/showvalidemail.php.txt
../code/str_case.phps
../code/str_split.phps
../code/strnpos.phps
../code/tail-10.phps
../code/tail-f.phps
../code/wordwrap_bigwords.phps
../code/testdir/dir2/dir2.2/subdir/1/2/3/deepfile
../code/testdir/dir2/dir2.2/testfile4
../code/testdir/dir2/testfile2
../code/testdir/dir3/testfile3
../code/testdir/testfile1
../code/200501152253
../code/404.php
../code/argparse.php
../code/array_unique_recursive.php
../code/bcceil.php
../code/code_debug_timing.php
../code/days_of_year.php
../code/dirlister.php
../code/dominicsayers.php
../code/foo.php
../code/ftruncate.php
../code/hexstr.php
../code/maillog.phps
../code/morse.php
../code/number_to_words.php
../code/number_to_words_apathy.php
../code/number_to_words_ex.php
../code/parse_str_quoted.inc.php
../code/rc4.inc.php
../code/rc4.php
../code/recursive_readdir.php
../code/runtimer.php
../code/showvalidemail2.php
../code/single_astmatch.php
../code/str_case.php
../code/str_rotN.php
../code/str_split.php
../code/strnpos.php
../code/tail-10.php
../code/tail-f.php
../code/tlds-alpha-by-domain.txt
../code/validate_email.inc.phps
../code/validate_email.inc.phps.bak
../code/wordwrap_bigwords.php
../code/rc4.inc.asp
../code/showvalidemail.php
../code/showvalidemail3.php
$files = preg_find('/./', '../code', PREG_FIND_DIRONLY|PREG_FIND_RECURSIVE); foreach($files as $file) printf("<br>%s\n", $file);Output:
../code/testdir
../code/testdir/dir2
../code/testdir/dir2/dir2.2
../code/testdir/dir2/dir2.2/subdir
../code/testdir/dir2/dir2.2/subdir/1
../code/testdir/dir2/dir2.2/subdir/1/2
../code/testdir/dir2/dir2.2/subdir/1/2/3
../code/testdir/dir3
$files = preg_find('/^str_.*?\.php$/D', '../code'); foreach($files as $file) printf("<br>%s\n", $file);Output:
../code/str_case.php
../code/str_rotN.php
../code/str_split.php
$files = preg_find('/^str_.*?\.php$/D', '../code', PREG_FIND_RETURNASSOC); print_r($files);Output:
Array
(
[../code/str_case.php] => Array
(
[stat] => Array
(
[0] => 2052
[1] => 2237604863
[2] => 33188
[3] => 1
[4] => 1000
[5] => 1000
[6] => 0
[7] => 2903
[8] => 1732032215
[9] => 1124413021
[10] => 1585957475
[11] => 4096
[12] => 8
[dev] => 2052
[ino] => 2237604863
[mode] => 33188
[nlink] => 1
[uid] => 1000
[gid] => 1000
[rdev] => 0
[size] => 2903
[atime] => 1732032215
[mtime] => 1124413021
[ctime] => 1585957475
[blksize] => 4096
[blocks] => 8
)
[du] => 4096
[uid] => 1000
[gid] => 1000
[filetype] => file
[mimetype] => text/x-php
[dirname] => ../code
[basename] => str_case.php
[ext] => php
[owner] =>
)
[../code/str_rotN.php] => Array
(
[stat] => Array
(
[0] => 2052
[1] => 2237613536
[2] => 33188
[3] => 1
[4] => 1000
[5] => 1000
[6] => 0
[7] => 652
[8] => 1732072619
[9] => 1180732295
[10] => 1585957475
[11] => 4096
[12] => 8
[dev] => 2052
[ino] => 2237613536
[mode] => 33188
[nlink] => 1
[uid] => 1000
[gid] => 1000
[rdev] => 0
[size] => 652
[atime] => 1732072619
[mtime] => 1180732295
[ctime] => 1585957475
[blksize] => 4096
[blocks] => 8
)
[du] => 4096
[uid] => 1000
[gid] => 1000
[filetype] => file
[mimetype] => text/x-php
[dirname] => ../code
[basename] => str_rotN.php
[ext] => php
[owner] =>
)
[../code/str_split.php] => Array
(
[stat] => Array
(
[0] => 2052
[1] => 2237613537
[2] => 33188
[3] => 1
[4] => 1000
[5] => 1000
[6] => 0
[7] => 745
[8] => 1732050679
[9] => 1154566256
[10] => 1585957475
[11] => 4096
[12] => 8
[dev] => 2052
[ino] => 2237613537
[mode] => 33188
[nlink] => 1
[uid] => 1000
[gid] => 1000
[rdev] => 0
[size] => 745
[atime] => 1732050679
[mtime] => 1154566256
[ctime] => 1585957475
[blksize] => 4096
[blocks] => 8
)
[du] => 4096
[uid] => 1000
[gid] => 1000
[filetype] => file
[mimetype] => text/x-php
[dirname] => ../code
[basename] => str_split.php
[ext] => php
[owner] =>
)
)
$files = preg_find('/./', '../code', PREG_FIND_SORTKEYS); foreach($files as $file) printf("<br>%s\n", $file);Output:
../code/200501152253
../code/404.php
../code/404.phps
../code/argparse.php
../code/array_unique_recursive.php
../code/array_unique_recursive.phps
../code/bcceil.php
../code/code_debug_timing.php
../code/days_of_year.php
../code/dirlister.php
../code/dirlister.phps
../code/dominicsayers.php
../code/foo.php
../code/ftruncate.php
../code/hexstr.php
../code/hexstr.phps
../code/maillog.phps
../code/morse.php
../code/morse.phps
../code/number_to_words.php
../code/number_to_words.phps
../code/number_to_words_apathy.php
../code/number_to_words_ex.php
../code/number_to_words_ex.phps
../code/parse_str_quoted.inc.php
../code/rc4.inc.asp
../code/rc4.inc.php
../code/rc4.inc.phps
../code/rc4.php
../code/rc4.phps
../code/recursive_readdir.php
../code/recursive_readdir.phps
../code/runtimer.php
../code/runtimer.phps
../code/showvalidemail.php
../code/showvalidemail.php.txt
../code/showvalidemail2.php
../code/showvalidemail3.php
../code/single_astmatch.php
../code/str_case.php
../code/str_case.phps
../code/str_rotN.php
../code/str_split.php
../code/str_split.phps
../code/strnpos.php
../code/strnpos.phps
../code/tail-10.php
../code/tail-10.phps
../code/tail-f.php
../code/tail-f.phps
../code/tlds-alpha-by-domain.txt
../code/validate_email.inc.phps
../code/validate_email.inc.phps.bak
../code/wordwrap_bigwords.php
../code/wordwrap_bigwords.phps
$files = preg_find('/./', '../code', PREG_FIND_SORTKEYS|PREG_FIND_SORTDESC); foreach($files as $file) printf("<br>%s\n", $file);Output:
../code/wordwrap_bigwords.phps
../code/wordwrap_bigwords.php
../code/validate_email.inc.phps.bak
../code/validate_email.inc.phps
../code/tlds-alpha-by-domain.txt
../code/tail-f.phps
../code/tail-f.php
../code/tail-10.phps
../code/tail-10.php
../code/strnpos.phps
../code/strnpos.php
../code/str_split.phps
../code/str_split.php
../code/str_rotN.php
../code/str_case.phps
../code/str_case.php
../code/single_astmatch.php
../code/showvalidemail3.php
../code/showvalidemail2.php
../code/showvalidemail.php.txt
../code/showvalidemail.php
../code/runtimer.phps
../code/runtimer.php
../code/recursive_readdir.phps
../code/recursive_readdir.php
../code/rc4.phps
../code/rc4.php
../code/rc4.inc.phps
../code/rc4.inc.php
../code/rc4.inc.asp
../code/parse_str_quoted.inc.php
../code/number_to_words_ex.phps
../code/number_to_words_ex.php
../code/number_to_words_apathy.php
../code/number_to_words.phps
../code/number_to_words.php
../code/morse.phps
../code/morse.php
../code/maillog.phps
../code/hexstr.phps
../code/hexstr.php
../code/ftruncate.php
../code/foo.php
../code/dominicsayers.php
../code/dirlister.phps
../code/dirlister.php
../code/days_of_year.php
../code/code_debug_timing.php
../code/bcceil.php
../code/array_unique_recursive.phps
../code/array_unique_recursive.php
../code/argparse.php
../code/404.phps
../code/404.php
../code/200501152253
$files = preg_find('/./', '../code', PREG_FIND_RECURSIVE|PREG_FIND_RETURNASSOC|PREG_FIND_SORTFILESIZE|PREG_FIND_SORTDESC); $i=1; foreach($files as $file => $stats) { printf('<br>%d) %d %s', $i, $stats['stat']['size'], $file); $i++; if ($i > 5) break; }Output:
1) 32065 ../code/showvalidemail3.php
2) 31899 ../code/showvalidemail.php.txt
3) 31899 ../code/showvalidemail.php
4) 30667 ../code/showvalidemail2.php
5) 13584 ../code/dominicsayers.php
$files = preg_find('/./', '../code', PREG_FIND_RECURSIVE|PREG_FIND_RETURNASSOC|PREG_FIND_SORTMODIFIED|PREG_FIND_SORTDESC); $i=1; foreach($files as $file => $stats) { printf('<br>%d) %s - %d bytes - %s', $i, date("Y-m-d H:i:s", $stats['stat']['mtime']), $stats['stat']['size'], $file); $i++; if ($i > 10) break; }Output:
1) 2021-05-11 15:07:29 - 31899 bytes - ../code/showvalidemail.php
2) 2021-05-11 15:07:29 - 31899 bytes - ../code/showvalidemail.php.txt
3) 2021-03-27 10:02:46 - 32065 bytes - ../code/showvalidemail3.php
4) 2021-03-26 21:11:02 - 3964 bytes - ../code/validate_email.inc.phps
5) 2020-02-25 16:50:57 - 30667 bytes - ../code/showvalidemail2.php
6) 2020-02-11 13:56:41 - 10213 bytes - ../code/tlds-alpha-by-domain.txt
7) 2019-12-19 17:21:47 - 1835 bytes - ../code/rc4.php
8) 2019-12-19 17:21:47 - 1835 bytes - ../code/rc4.phps
9) 2019-12-19 17:12:35 - 1963 bytes - ../code/rc4.inc.phps
10) 2019-12-19 17:12:35 - 1963 bytes - ../code/rc4.inc.php
Files in testdir, recursive: Array ( [0] => ../code/testdir/dir2/dir2.2/subdir/1/2/3/deepfile [1] => ../code/testdir/dir2/dir2.2/testfile4 [2] => ../code/testdir/dir2/testfile2 [3] => ../code/testdir/dir3/testfile3 [4] => ../code/testdir/testfile1 )
Files, recursive, in date modified order:
1589744521 - 2020-05-17 19:42:01 - ./preg_find.php.txt 1589744521 - 2020-05-17 19:42:01 - ./preg_find.phps 1589744521 - 2020-05-17 19:42:01 - ./preg_find.php 1589744521 - 2020-05-17 19:42:01 - ./preg_find_2.4.php 1589743825 - 2020-05-17 19:30:25 - ./.preg_find_2.4.php.swp 1589743559 - 2020-05-17 19:25:59 - ./preg_find_ex_2.3.php 1589743551 - 2020-05-17 19:25:51 - ./preg_find_2.3.php 1589743294 - 2020-05-17 19:21:34 - ./preg_find_ex_2.4.php 1589743294 - 2020-05-17 19:21:34 - ./preg_find_ex.phps 1589743294 - 2020-05-17 19:21:34 - ./preg_find_ex.php 1379285917 - 2013-09-15 22:58:37 - ./cisco.txt 1302473128 - 2011-04-10 22:05:28 - ./old/2.0/preg_find.php 1302473128 - 2011-04-10 22:05:28 - ./old/2.0/preg_find.phps 1244846831 - 2009-06-12 22:47:11 - ./old/2.3/preg_find.php 1244846815 - 2009-06-12 22:46:55 - ./old/2.2/preg_find.php 1216163127 - 2008-07-15 23:05:27 - ./old/2.1/preg_find.php 1176804073 - 2007-04-17 10:01:13 - ./old/2.0/preg_find_ex.php 1176804073 - 2007-04-17 10:01:13 - ./old/2.0/preg_find_ex.phps
Files in ../code, recursive, in alphabetical order:
Array ( [23] => ../code/200501152253 [24] => ../code/404.php [0] => ../code/404.phps [25] => ../code/argparse.php [26] => ../code/array_unique_recursive.php [1] => ../code/array_unique_recursive.phps [27] => ../code/bcceil.php [28] => ../code/code_debug_timing.php [29] => ../code/days_of_year.php [30] => ../code/dirlister.php [2] => ../code/dirlister.phps [31] => ../code/dominicsayers.php [32] => ../code/foo.php [33] => ../code/ftruncate.php [34] => ../code/hexstr.php [3] => ../code/hexstr.phps [35] => ../code/maillog.phps [36] => ../code/morse.php [4] => ../code/morse.phps [37] => ../code/number_to_words.php [5] => ../code/number_to_words.phps [38] => ../code/number_to_words_apathy.php [39] => ../code/number_to_words_ex.php [6] => ../code/number_to_words_ex.phps [40] => ../code/parse_str_quoted.inc.php [57] => ../code/rc4.inc.asp [41] => ../code/rc4.inc.php [7] => ../code/rc4.inc.phps [42] => ../code/rc4.php [8] => ../code/rc4.phps [43] => ../code/recursive_readdir.php [9] => ../code/recursive_readdir.phps [44] => ../code/runtimer.php [10] => ../code/runtimer.phps [58] => ../code/showvalidemail.php [11] => ../code/showvalidemail.php.txt [45] => ../code/showvalidemail2.php [59] => ../code/showvalidemail3.php [46] => ../code/single_astmatch.php [47] => ../code/str_case.php [12] => ../code/str_case.phps [48] => ../code/str_rotN.php [49] => ../code/str_split.php [13] => ../code/str_split.phps [50] => ../code/strnpos.php [14] => ../code/strnpos.phps [51] => ../code/tail-10.php [15] => ../code/tail-10.phps [52] => ../code/tail-f.php [16] => ../code/tail-f.phps [18] => ../code/testdir/dir2/dir2.2/subdir/1/2/3/deepfile [19] => ../code/testdir/dir2/dir2.2/testfile4 [20] => ../code/testdir/dir2/testfile2 [21] => ../code/testdir/dir3/testfile3 [22] => ../code/testdir/testfile1 [53] => ../code/tlds-alpha-by-domain.txt [54] => ../code/validate_email.inc.phps [55] => ../code/validate_email.inc.phps.bak [56] => ../code/wordwrap_bigwords.php [17] => ../code/wordwrap_bigwords.phps )
Files in ../code, recursive, in alphabetical order on file basename:
Array ( [0] => ../code/200501152253 [1] => ../code/404.php [2] => ../code/404.phps [3] => ../code/argparse.php [4] => ../code/array_unique_recursive.php [5] => ../code/array_unique_recursive.phps [6] => ../code/bcceil.php [7] => ../code/code_debug_timing.php [8] => ../code/days_of_year.php [9] => ../code/testdir/dir2/dir2.2/subdir/1/2/3/deepfile [10] => ../code/dirlister.php [11] => ../code/dirlister.phps [12] => ../code/dominicsayers.php [13] => ../code/foo.php [14] => ../code/ftruncate.php [15] => ../code/hexstr.php [16] => ../code/hexstr.phps [17] => ../code/maillog.phps [18] => ../code/morse.php [19] => ../code/morse.phps [20] => ../code/number_to_words.php [21] => ../code/number_to_words.phps [22] => ../code/number_to_words_apathy.php [23] => ../code/number_to_words_ex.php [24] => ../code/number_to_words_ex.phps [25] => ../code/parse_str_quoted.inc.php [26] => ../code/rc4.inc.asp [27] => ../code/rc4.inc.php [28] => ../code/rc4.inc.phps [29] => ../code/rc4.php [30] => ../code/rc4.phps [31] => ../code/recursive_readdir.php [32] => ../code/recursive_readdir.phps [33] => ../code/runtimer.php [34] => ../code/runtimer.phps [35] => ../code/showvalidemail.php [36] => ../code/showvalidemail.php.txt [37] => ../code/showvalidemail2.php [38] => ../code/showvalidemail3.php [39] => ../code/single_astmatch.php [40] => ../code/str_case.php [41] => ../code/str_case.phps [42] => ../code/str_rotN.php [43] => ../code/str_split.php [44] => ../code/str_split.phps [45] => ../code/strnpos.php [46] => ../code/strnpos.phps [47] => ../code/tail-10.php [48] => ../code/tail-10.phps [49] => ../code/tail-f.php [50] => ../code/tail-f.phps [51] => ../code/testdir/testfile1 [52] => ../code/testdir/dir2/testfile2 [53] => ../code/testdir/dir3/testfile3 [54] => ../code/testdir/dir2/dir2.2/testfile4 [55] => ../code/tlds-alpha-by-domain.txt [56] => ../code/validate_email.inc.phps [57] => ../code/validate_email.inc.phps.bak [58] => ../code/wordwrap_bigwords.php [59] => ../code/wordwrap_bigwords.phps )
Files in ../code, recursive, in reverse file size order:
32065 bytes - 2021-03-27 10:02:46 - ../code/showvalidemail3.php 31899 bytes - 2021-05-11 15:07:29 - ../code/showvalidemail.php.txt 31899 bytes - 2021-05-11 15:07:29 - ../code/showvalidemail.php 30667 bytes - 2020-02-25 16:50:57 - ../code/showvalidemail2.php 13584 bytes - 2009-02-25 16:46:34 - ../code/dominicsayers.php 12595 bytes - 2003-11-05 13:27:47 - ../code/rc4.inc.asp 10213 bytes - 2020-02-11 13:56:41 - ../code/tlds-alpha-by-domain.txt 5987 bytes - 2009-02-21 14:59:11 - ../code/dirlister.php 5987 bytes - 2009-02-21 14:59:11 - ../code/dirlister.phps 3964 bytes - 2021-03-26 21:11:02 - ../code/validate_email.inc.phps 3184 bytes - 2010-03-31 14:24:56 - ../code/404.phps 3184 bytes - 2010-03-31 14:24:56 - ../code/404.php 3155 bytes - 2009-04-23 21:34:30 - ../code/tail-10.phps 3155 bytes - 2009-04-23 21:34:30 - ../code/tail-10.php 2997 bytes - 2006-05-24 14:22:31 - ../code/number_to_words.php 2997 bytes - 2006-05-24 14:22:31 - ../code/number_to_words.phps 2903 bytes - 2005-08-19 00:57:01 - ../code/str_case.phps 2903 bytes - 2005-08-19 00:57:01 - ../code/str_case.php 2606 bytes - 2010-11-29 17:02:30 - ../code/parse_str_quoted.inc.php 2246 bytes - 2008-08-10 19:34:44 - ../code/array_unique_recursive.php 2246 bytes - 2008-08-10 19:34:44 - ../code/array_unique_recursive.phps 2013 bytes - 2007-10-01 22:58:02 - ../code/code_debug_timing.php 2012 bytes - 2006-05-24 14:33:30 - ../code/number_to_words_apathy.php 1963 bytes - 2019-12-19 17:12:35 - ../code/rc4.inc.php 1963 bytes - 2019-12-19 17:12:35 - ../code/rc4.inc.phps 1835 bytes - 2019-12-19 17:21:47 - ../code/rc4.php 1835 bytes - 2019-12-19 17:21:47 - ../code/rc4.phps 1827 bytes - 2008-05-29 00:59:40 - ../code/validate_email.inc.phps.bak 1497 bytes - 2007-06-08 10:50:50 - ../code/morse.phps 1497 bytes - 2007-06-08 10:50:50 - ../code/morse.php 1467 bytes - 2005-08-05 13:10:19 - ../code/maillog.phps 1322 bytes - 2009-02-19 19:00:43 - ../code/hexstr.php 1322 bytes - 2009-02-19 19:00:43 - ../code/hexstr.phps 1260 bytes - 2005-08-05 12:32:37 - ../code/strnpos.phps 1260 bytes - 2005-08-05 12:32:37 - ../code/strnpos.php 1126 bytes - 2007-05-16 09:41:20 - ../code/recursive_readdir.php 1126 bytes - 2007-05-16 09:41:20 - ../code/recursive_readdir.phps 950 bytes - 2005-01-15 22:53:12 - ../code/wordwrap_bigwords.phps 950 bytes - 2005-01-15 22:53:12 - ../code/wordwrap_bigwords.php 745 bytes - 2006-08-03 00:50:56 - ../code/str_split.phps 745 bytes - 2006-08-03 00:50:56 - ../code/str_split.php 681 bytes - 2008-05-06 19:09:31 - ../code/bcceil.php 676 bytes - 2008-01-11 16:49:50 - ../code/tail-f.php 676 bytes - 2008-01-11 16:49:50 - ../code/tail-f.phps 652 bytes - 2007-06-01 21:11:35 - ../code/str_rotN.php 600 bytes - 2007-05-16 10:48:40 - ../code/runtimer.php 600 bytes - 2007-05-16 10:48:40 - ../code/runtimer.phps 491 bytes - 2008-03-10 10:48:13 - ../code/ftruncate.php 481 bytes - 2007-06-01 21:29:03 - ../code/days_of_year.php 374 bytes - 2006-05-24 16:13:36 - ../code/number_to_words_ex.phps 374 bytes - 2006-05-24 16:13:36 - ../code/number_to_words_ex.php 294 bytes - 2006-06-26 14:52:38 - ../code/argparse.php 231 bytes - 2005-08-11 00:01:04 - ../code/single_astmatch.php 41 bytes - 2006-05-25 12:20:04 - ../code/foo.php 0 bytes - 2006-11-01 14:33:21 - ../code/testdir/dir2/testfile2 0 bytes - 2005-01-18 17:29:58 - ../code/200501152253 0 bytes - 2006-11-01 14:33:37 - ../code/testdir/dir3/testfile3 0 bytes - 2006-11-01 14:33:10 - ../code/testdir/testfile1 0 bytes - 2006-11-01 14:34:32 - ../code/testdir/dir2/dir2.2/testfile4 0 bytes - 2006-11-01 14:36:01 - ../code/testdir/dir2/dir2.2/subdir/1/2/3/deepfile