Need solution
Posted: Fri Sep 19, 2008 6:36 am
Hi All
I m having problem regarding string,I try to explain i have all the directories, And an array list in which i have some extension like php cgi etc.i am looping through directories to find the files with php cgi extension,if those found print dir name and count.problem is dir name are printing many time in loop i paste my code.When i print dir name out off loop still get dir name many times.One thing more variable $dir_name contain all the dir name which i m getting from an other function.
if( $files[$k] != '.htaccess' && $files[$k]!='.' && $files[$k]!='..' && !is_dir($files[$k] )){
$ext = substr($files[$k], strrpos($files[$k], '.') + 1);
if(in_array($ext,$list)){
$cnt++;
echo dir_name;
OutPut
/var/www/html/test/abc _Writable_dir_unusual_file 1
/var/www/html/test2 _Writable_dir_unusual_file 1
var/www/html/test3 _Writable_dir_unusual_file 1
var/www/html/test3 _Writable_dir_unusual_file 2
/var/www/html/test3 _Writable_dir_unusual_file 3
I m having problem regarding string,I try to explain i have all the directories, And an array list in which i have some extension like php cgi etc.i am looping through directories to find the files with php cgi extension,if those found print dir name and count.problem is dir name are printing many time in loop i paste my code.When i print dir name out off loop still get dir name many times.One thing more variable $dir_name contain all the dir name which i m getting from an other function.
if( $files[$k] != '.htaccess' && $files[$k]!='.' && $files[$k]!='..' && !is_dir($files[$k] )){
$ext = substr($files[$k], strrpos($files[$k], '.') + 1);
if(in_array($ext,$list)){
$cnt++;
echo dir_name;
OutPut
/var/www/html/test/abc _Writable_dir_unusual_file 1
/var/www/html/test2 _Writable_dir_unusual_file 1
var/www/html/test3 _Writable_dir_unusual_file 1
var/www/html/test3 _Writable_dir_unusual_file 2
/var/www/html/test3 _Writable_dir_unusual_file 3