View all .txt files

Тема закрыта
516
.
I want to view my server all .txt ext files.

Output:
filename: exam.txt
path: new/wap/exam.txt

help me..
.
(\/)____o_O____(\/)
Sohel,
$array = array();
$dir = realpath('.');
$fileSPLObjects =  new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir), RecursiveIteratorIterator::CHILD_FIRST);
foreach($fileSPLObjects as $fullFileName => $fileSPLObject ) {
if ($fileSPLObject->isFile()) {
$info = new SplFileInfo($fullFileName);    
if ($info->getExtension() == 'txt') {
$array[] = $fullFileName;    
}
}
}

echo '<pre>';
print_r($array);


file in root
(PHP 5 >= 5.3.6)

result
Array
(
    [0] => D:\all\ALL\www\openserver\domains\localhost\5l\1library\java\menu.txt
    [1] => D:\all\ALL\www\openserver\domains\localhost\5l\1library\java\textfile.txt
    [2] => D:\all\ALL\www\openserver\domains\localhost\5l\INSTALL.txt
    [3] => D:\all\ALL\www\openserver\domains\localhost\5l\LICENSE.txt
    [4] => D:\all\ALL\www\openserver\domains\localhost\5l\README.txt
    [5] => D:\all\ALL\www\openserver\domains\localhost\5l\robots.txt
    [6] => D:\all\ALL\www\openserver\domains\localhost\5l\VERSION.txt
    [7] => D:\all\ALL\www\openserver\domains\localhost\ajax\1.txt
    [8] => D:\all\ALL\www\openserver\domains\localhost\ajax\log.txt
    [9] => D:\all\ALL\www\openserver\domains\localhost\ajax2\log.txt
    [10] => D:\all\ALL\www\openserver\domains\localhost\calc\1.txt
    [11] => D:\all\ALL\www\openserver\domains\localhost\calc\cookie.txt
    [12] => D:\all\ALL\www\openserver\domains\localhost\curl\1\cookie.txt
    [13] => D:\all\ALL\www\openserver\domains\localhost\dnl\1\readme.txt
    [14] => D:\all\ALL\www\openserver\domains\localhost\dnl\test\cookies.txt
    [15] => D:\all\ALL\www\openserver\domains\localhost\dnl\test2\cookies.txt
    [16] => D:\all\ALL\www\openserver\domains\localhost\dnl\upl\1.txt
    [17] => D:\all\ALL\www\openserver\domains\localhost\dnl\upl\2.txt
    [18] => D:\all\ALL\www\openserver\domains\localhost\dnl\upl\3.txt
    [19] => D:\all\ALL\www\openserver\domains\localhost\dnl\upl\4.txt
    [20] => D:\all\ALL\www\openserver\domains\localhost\get\admin\mp3tool\readme.txt
    [21] => D:\all\ALL\www\openserver\domains\localhost\get\admin\readme.txt
    [22] => D:\all\ALL\www\openserver\domains\localhost\j322\forum\files\robots.txt
    [23] => D:\all\ALL\www\openserver\domains\localhost\j322\install\data\vopros.txt
    [24] => D:\all\ALL\www\openserver\domains\localhost\j322\install.txt
    [25] => D:\all\ALL\www\openserver\domains\localhost\j322\library\java\menu.txt
    [26] => D:\all\ALL\www\openserver\domains\localhost\j322\library\java\textfile.txt
    [27] => D:\all\ALL\www\openserver\domains\localhost\j322\license.txt
    [28] => D:\all\ALL\www\openserver\domains\localhost\j322\pages\actmail.txt
    [29] => D:\all\ALL\www\openserver\domains\localhost\j322\pages\forum.txt
    [30] => D:\all\ALL\www\openserver\domains\localhost\j322\pages\forumfaq.txt
    [31] => D:\all\ALL\www\openserver\domains\localhost\j322\pages\trans.txt
    [32] => D:\all\ALL\www\openserver\domains\localhost\j322\readme.txt
    [33] => D:\all\ALL\www\openserver\domains\localhost\j322\version.txt
    [34] => D:\all\ALL\www\openserver\domains\localhost\j451\INSTALL.txt
    [35] => D:\all\ALL\www\openserver\domains\localhost\j451\klib\tz.txt
    [36] => D:\all\ALL\www\openserver\domains\localhost\j451\library\java\menu.txt
    [37] => D:\all\ALL\www\openserver\domains\localhost\j451\library\java\textfile.txt
    [38] => D:\all\ALL\www\openserver\domains\localhost\j451\LICENSE.txt
    [39] => D:\all\ALL\www\openserver\domains\localhost\j451\README.txt
    [40] => D:\all\ALL\www\openserver\domains\localhost\j451\robots.txt
    [41] => D:\all\ALL\www\openserver\domains\localhost\j451\VERSION.txt
    [42] => D:\all\ALL\www\openserver\domains\localhost\j5\cookie.txt
    [43] => D:\all\ALL\www\openserver\domains\localhost\j5\files\forum\attach\1212.txt
    [44] => D:\all\ALL\www\openserver\domains\localhost\j5\files\forum\attach\robots.txt
    [45] => D:\all\ALL\www\openserver\domains\localhost\j5\INSTALL.txt
    [46] => D:\all\ALL\www\openserver\domains\localhost\j5\j5lib\tz.txt
    [47] => D:\all\ALL\www\openserver\domains\localhost\j5\kfm\readme.txt
    [48] => D:\all\ALL\www\openserver\domains\localhost\j5\klib\tz.txt
    [49] => D:\all\ALL\www\openserver\domains\localhost\j5\library\java\menu.txt
    [50] => D:\all\ALL\www\openserver\domains\localhost\j5\library\java\textfile.txt
    [51] => D:\all\ALL\www\openserver\domains\localhost\j5\LICENSE.txt
    [52] => D:\all\ALL\www\openserver\domains\localhost\j5\README.txt
    [53] => D:\all\ALL\www\openserver\domains\localhost\j5\robots.txt
    [54] => D:\all\ALL\www\openserver\domains\localhost\j5\test.txt
    [55] => D:\all\ALL\www\openserver\domains\localhost\j5\VERSION.txt
    [56] => D:\all\ALL\www\openserver\domains\localhost\j521\INSTALL.txt
    [57] => D:\all\ALL\www\openserver\domains\localhost\j521\library\java\menu.txt
    [58] => D:\all\ALL\www\openserver\domains\localhost\j521\library\java\textfile.txt
    [59] => D:\all\ALL\www\openserver\domains\localhost\j521\LICENSE.txt
    [60] => D:\all\ALL\www\openserver\domains\localhost\j521\README.txt
    [61] => D:\all\ALL\www\openserver\domains\localhost\j521\robots.txt
    [62] => D:\all\ALL\www\openserver\domains\localhost\j521\VERSION.txt
    [63] => D:\all\ALL\www\openserver\domains\localhost\j521lib\1library\java\menu.txt
    [64] => D:\all\ALL\www\openserver\domains\localhost\j521lib\1library\java\textfile.txt
    [65] => D:\all\ALL\www\openserver\domains\localhost\j521lib\INSTALL.txt
    [66] => D:\all\ALL\www\openserver\domains\localhost\j521lib\LICENSE.txt
    [67] => D:\all\ALL\www\openserver\domains\localhost\j521lib\README.txt
    [68] => D:\all\ALL\www\openserver\domains\localhost\j521lib\robots.txt
    [69] => D:\all\ALL\www\openserver\domains\localhost\j521lib\VERSION.txt
    [70] => D:\all\ALL\www\openserver\domains\localhost\j521w\download\test.txt
    [71] => D:\all\ALL\www\openserver\domains\localhost\j521w\INSTALL.txt
    [72] => D:\all\ALL\www\openserver\domains\localhost\j521w\library\java\menu.txt
    [73] => D:\all\ALL\www\openserver\domains\localhost\j521w\library\java\textfile.txt
    [74] => D:\all\ALL\www\openserver\domains\localhost\j521w\LICENSE.txt
    [75] => D:\all\ALL\www\openserver\domains\localhost\j521w\README.txt
    [76] => D:\all\ALL\www\openserver\domains\localhost\j521w\robots.txt
    [77] => D:\all\ALL\www\openserver\domains\localhost\j521w\VERSION.txt
    [78] => D:\all\ALL\www\openserver\domains\localhost\j55\api\readme.txt
    [79] => D:\all\ALL\www\openserver\domains\localhost\j55\download\test.txt
    [80] => D:\all\ALL\www\openserver\domains\localhost\j55\INSTALL.txt
    [81] => D:\all\ALL\www\openserver\domains\localhost\j55\j5lib\_dev\tz.txt
    [82] => D:\all\ALL\www\openserver\domains\localhost\j55\kfm\readme.txt
    [83] => D:\all\ALL\www\openserver\domains\localhost\j55\library\java\menu.txt
    [84] => D:\all\ALL\www\openserver\domains\localhost\j55\library\java\textfile.txt
    [85] => D:\all\ALL\www\openserver\domains\localhost\j55\LICENSE.txt
    [86] => D:\all\ALL\www\openserver\domains\localhost\j55\README.txt
    [87] => D:\all\ALL\www\openserver\domains\localhost\j55\robots.txt
    [88] => D:\all\ALL\www\openserver\domains\localhost\j55\VERSION.txt
    [89] => D:\all\ALL\www\openserver\domains\localhost\j5lib\tz.txt
    [90] => D:\all\ALL\www\openserver\domains\localhost\kfor\test_f_tree.txt
    [91] => D:\all\ALL\www\openserver\domains\localhost\ksw\INSTALL.txt
    [92] => D:\all\ALL\www\openserver\domains\localhost\ksw\library\java\menu.txt
    [93] => D:\all\ALL\www\openserver\domains\localhost\ksw\library\java\textfile.txt
    [94] => D:\all\ALL\www\openserver\domains\localhost\ksw\LICENSE.txt
    [95] => D:\all\ALL\www\openserver\domains\localhost\ksw\README.txt
    [96] => D:\all\ALL\www\openserver\domains\localhost\ksw\robots.txt
    [97] => D:\all\ALL\www\openserver\domains\localhost\ksw\VERSION.txt
    [98] => D:\all\ALL\www\openserver\domains\localhost\ksw2\INSTALL.txt
    [99] => D:\all\ALL\www\openserver\domains\localhost\ksw2\library\java\menu.txt
    [100] => D:\all\ALL\www\openserver\domains\localhost\ksw2\library\java\textfile.txt
    [101] => D:\all\ALL\www\openserver\domains\localhost\ksw2\LICENSE.txt
    [102] => D:\all\ALL\www\openserver\domains\localhost\ksw2\README.txt
    [103] => D:\all\ALL\www\openserver\domains\localhost\ksw2\robots.txt
    [104] => D:\all\ALL\www\openserver\domains\localhost\ksw2\VERSION.txt
    [105] => D:\all\ALL\www\openserver\domains\localhost\kzip\exemple\j5\тест\тест\тест\тест.txt
    [106] => D:\all\ALL\www\openserver\domains\localhost\kzip\exemple\j5\тест\тест.txt
    [107] => D:\all\ALL\www\openserver\domains\localhost\mobicms\files\download\temp\created_java\java\menu.txt
    [108] => D:\all\ALL\www\openserver\domains\localhost\mobicms\files\download\temp\created_java\java\textfile.txt
    [109] => D:\all\ALL\www\openserver\domains\localhost\mobicms\includes\logs\ip_requests_list.txt
    [110] => D:\all\ALL\www\openserver\domains\localhost\mobicms\modules\library\_java\menu.txt
    [111] => D:\all\ALL\www\openserver\domains\localhost\mobicms\modules\library\_java\textfile.txt
    [112] => D:\all\ALL\www\openserver\domains\localhost\mobicms\README.txt
    [113] => D:\all\ALL\www\openserver\domains\localhost\mobicms\robots.txt
    [114] => D:\all\ALL\www\openserver\domains\localhost\mobicms\templates\_default\readme.txt
    [115] => D:\all\ALL\www\openserver\domains\localhost\mobicms\VERSION.txt
    [116] => D:\all\ALL\www\openserver\domains\localhost\mp3\ID3\changelog.txt
    [117] => D:\all\ALL\www\openserver\domains\localhost\mp3\ID3\dependencies.txt
    [118] => D:\all\ALL\www\openserver\domains\localhost\mp3\ID3\helperapps\readme.helperapps.txt
    [119] => D:\all\ALL\www\openserver\domains\localhost\mp3\ID3\license.txt
    [120] => D:\all\ALL\www\openserver\domains\localhost\mp3\ID3\licenses\licence.gpl-10.txt
    [121] => D:\all\ALL\www\openserver\domains\localhost\mp3\ID3\licenses\licence.gpl-20.txt
    [122] => D:\all\ALL\www\openserver\domains\localhost\mp3\ID3\licenses\licence.gpl-30.txt
    [123] => D:\all\ALL\www\openserver\domains\localhost\mp3\ID3\licenses\licence.lgpl-30.txt
    [124] => D:\all\ALL\www\openserver\domains\localhost\mp3\ID3\licenses\licence.mpl-20.txt
    [125] => D:\all\ALL\www\openserver\domains\localhost\mp3\ID3\licenses\license.commercial.txt
    [126] => D:\all\ALL\www\openserver\domains\localhost\mp3\ID3\readme.txt
    [127] => D:\all\ALL\www\openserver\domains\localhost\mp3\ID3\structure.txt
    [128] => D:\all\ALL\www\openserver\domains\localhost\phplot\contrib\README.txt
    [129] => D:\all\ALL\www\openserver\domains\localhost\phplot\NEWS.txt
    [130] => D:\all\ALL\www\openserver\domains\localhost\phplot\NEWS_part1.txt
    [131] => D:\all\ALL\www\openserver\domains\localhost\phplot\README.txt
    [132] => D:\all\ALL\www\openserver\domains\localhost\sitemap\cookie.txt
    [133] => D:\all\ALL\www\openserver\domains\localhost\testus\tmp\log.txt
    [134] => D:\all\ALL\www\openserver\domains\localhost\testus2\83.219.138.206.txt
    [135] => D:\all\ALL\www\openserver\domains\localhost\testus2\logs\2014-03-22\127.0.0.1.txt
    [136] => D:\all\ALL\www\openserver\domains\localhost\testus2\robots.txt
    [137] => D:\all\ALL\www\openserver\domains\localhost\testus3\log.txt
    [138] => D:\all\ALL\www\openserver\domains\localhost\testus3\logs\2014-03-29\109.191.143.152.txt
    [139] => D:\all\ALL\www\openserver\domains\localhost\testus3\logs\2014-03-29\141.8.191.2.txt
    [140] => D:\all\ALL\www\openserver\domains\localhost\testus3\logs\2014-03-29\144.76.176.17.txt
    [141] => D:\all\ALL\www\openserver\domains\localhost\testus3\logs\2014-03-29\157.55.33.109.txt
    [142] => D:\all\ALL\www\openserver\domains\localhost\testus3\logs\2014-03-29\176.8.234.165.txt
    [143] => D:\all\ALL\www\openserver\domains\localhost\testus3\logs\2014-03-29\178.154.224.114.txt
    [144] => D:\all\ALL\www\openserver\domains\localhost\testus3\logs\2014-03-29\178.68.29.107.txt
    [145] => D:\all\ALL\www\openserver\domains\localhost\testus3\logs\2014-03-29\182.118.20.170.txt
    [146] => D:\all\ALL\www\openserver\domains\localhost\testus3\logs\2014-03-29\195.54.213.174.txt
    [147] => D:\all\ALL\www\openserver\domains\localhost\testus3\logs\2014-03-29\198.143.187.202.txt
    [148] => D:\all\ALL\www\openserver\domains\localhost\testus3\logs\2014-03-29\208.107.32.152.txt
    [149] => D:\all\ALL\www\openserver\domains\localhost\testus3\logs\2014-03-29\213.180.206.197.txt
    [150] => D:\all\ALL\www\openserver\domains\localhost\testus3\logs\2014-03-29\216.107.155.114.txt
    [151] => D:\all\ALL\www\openserver\domains\localhost\testus3\logs\2014-03-29\217.69.133.238.txt
    [152] => D:\all\ALL\www\openserver\domains\localhost\testus3\logs\2014-03-29\404.txt
    [153] => D:\all\ALL\www\openserver\domains\localhost\testus3\logs\2014-03-29\46.165.197.142.txt
    [154] => D:\all\ALL\www\openserver\domains\localhost\testus3\logs\2014-03-29\5.10.83.11.txt
    [155] => D:\all\ALL\www\openserver\domains\localhost\testus3\logs\2014-03-29\5.10.83.13.txt
    [156] => D:\all\ALL\www\openserver\domains\localhost\testus3\logs\2014-03-29\5.10.83.19.txt
    [157] => D:\all\ALL\www\openserver\domains\localhost\testus3\logs\2014-03-29\5.10.83.26.txt
    [158] => D:\all\ALL\www\openserver\domains\localhost\testus3\logs\2014-03-29\5.10.83.41.txt
    [159] => D:\all\ALL\www\openserver\domains\localhost\testus3\logs\2014-03-29\5.10.83.45.txt
    [160] => D:\all\ALL\www\openserver\domains\localhost\testus3\logs\2014-03-29\5.10.83.52.txt
    [161] => D:\all\ALL\www\openserver\domains\localhost\testus3\logs\2014-03-29\5.10.83.61.txt
    [162] => D:\all\ALL\www\openserver\domains\localhost\testus3\logs\2014-03-29\5.10.83.64.txt
    [163] => D:\all\ALL\www\openserver\domains\localhost\testus3\logs\2014-03-29\5.10.83.65.txt
    [164] => D:\all\ALL\www\openserver\domains\localhost\testus3\logs\2014-03-29\5.10.83.7.txt
    [165] => D:\all\ALL\www\openserver\domains\localhost\testus3\logs\2014-03-29\5.10.83.74.txt
    [166] => D:\all\ALL\www\openserver\domains\localhost\testus3\logs\2014-03-29\5.10.83.80.txt
    [167] => D:\all\ALL\www\openserver\domains\localhost\testus3\logs\2014-03-29\5.10.83.87.txt
    [168] => D:\all\ALL\www\openserver\domains\localhost\testus3\logs\2014-03-29\5.10.83.92.txt
    [169] => D:\all\ALL\www\openserver\domains\localhost\testus3\logs\2014-03-29\5.10.83.95.txt
    [170] => D:\all\ALL\www\openserver\domains\localhost\testus3\logs\2014-03-29\5.255.210.93.txt
    [171] => D:\all\ALL\www\openserver\domains\localhost\testus3\logs\2014-03-29\5.255.253.59.txt
    [172] => D:\all\ALL\www\openserver\domains\localhost\testus3\logs\2014-03-29\66.249.66.73.txt
    [173] => D:\all\ALL\www\openserver\domains\localhost\testus3\logs\2014-03-29\66.249.70.163.txt
    [174] => D:\all\ALL\www\openserver\domains\localhost\testus3\logs\2014-03-29\66.249.74.51.txt
    [175] => D:\all\ALL\www\openserver\domains\localhost\testus3\logs\2014-03-29\66.249.78.145.txt
    [176] => D:\all\ALL\www\openserver\domains\localhost\testus3\logs\2014-03-29\68.180.224.238.txt
    [177] => D:\all\ALL\www\openserver\domains\localhost\testus3\logs\2014-03-29\77.88.59.64.txt
    [178] => D:\all\ALL\www\openserver\domains\localhost\testus3\logs\2014-03-29\83.219.138.209.txt
    [179] => D:\all\ALL\www\openserver\domains\localhost\testus3\logs\2014-03-29\83.219.138.237.txt
    [180] => D:\all\ALL\www\openserver\domains\localhost\testus3\logs\2014-03-29\83.219.138.251.txt
    [181] => D:\all\ALL\www\openserver\domains\localhost\testus3\logs\2014-03-29\92.232.53.54.txt
    [182] => D:\all\ALL\www\openserver\domains\localhost\testus3\logs\2014-03-29\95.108.129.207.txt
    [183] => D:\all\ALL\www\openserver\domains\localhost\testus3\robots.txt
    [184] => D:\all\ALL\www\openserver\domains\localhost\tree\2-12-13\_dev\tz.txt
    [185] => D:\all\ALL\www\openserver\domains\localhost\wapweb\11\README.txt
    [186] => D:\all\ALL\www\openserver\domains\localhost\wf\1cookie.txt
)
.
Thank bro..
Всего: 3