You are here: Help with loop « PHP Programming Language « IT news, forums, messages
Help with loop

Posted by Scoop on 09/30/06 14:50

I am new to php and not much of a developer to begin with. I am trying
to write what seems like it should be a simple piece of code but I
can't get it to work.

I'm trying to check if a file exists. If it is in the directory where
the php page is, I'd like to echo the name of the file. If it doesn't
exist, I'd like to back up a directory and check again. I'd like it to
continue backing up, one directory at a time until the file is found,
then echo the relative file location as ../../file.html where there is
one ../ per directory that needed to be traversed. Here is what I
have:

<?php
$file_path = 'file.htm';
do {
$globcheck = glob($file_path);
$homefile_path = '../'.$file_path;
} while(!empty($globcheck));
?>
<?php echo $file_path; ?>

Can someone tell me what I'm doing wrong?

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация