Need solution

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
aliahsan81
Forum Newbie
Posts: 8
Joined: Thu Sep 04, 2008 4:46 pm

Need solution

Post by aliahsan81 »

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
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: Need solution

Post by pickle »

[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1 wrote:2. Use descriptive subjects when you start a new thread. Vague titles such as "Help!", "Why?" are misleading and keep you from receiving an answer to your question.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
yacahuma
Forum Regular
Posts: 870
Joined: Sun Jul 01, 2007 7:11 am

Re: Need solution

Post by yacahuma »

are you doing deep search(are you going all the way down in the dir structure?)
Post Reply