Author Topic: I AM ANGERED.  (Read 1162 times)

TheQuirk

  • VIP
  • Member
  • ***
  • Posts: 2,154
  • Kudos: 315
I AM ANGERED.
« on: 10 January 2003, 04:18 »
Wiggin. What's up with this?

 
quote:
<? $maindir = "./" ; $mydir = opendir($maindir) ; $exclude = array("index.php","..",".","*.php"); while($fn = readdir($mydir)) { if ($fn == $exclude[4] || $fn == $exclude[1]) continue; echo "<br><a href='$fn' target=\"_blank\">$fn</a>"; } closedir($mydir); ?>


Output:

 
quote:

.
jesus_vs_tool.txt <--What's THIS does here?
K2CKabani.htm
OutAcOntRoLL187.htm
<SNIP>
sys0p.txt
TheComMercials02.htm
index.php  <--What's THIS doing here?


voidmain

  • VIP
  • Member
  • ***
  • Posts: 5,605
  • Kudos: 184
    • http://voidmain.is-a-geek.net/
I AM ANGERED.
« Reply #1 on: 10 January 2003, 05:10 »
Uh, could you be a little more specific? Obviously the first part is a piece of PHP code. I assume the second part is a list of files produced by the PHP code. But I don't understand what you are angry about. Unless you didn't write the code or place the files in question in a place that you control.
Someone please remove this account. Thanks...

TheQuirk

  • VIP
  • Member
  • ***
  • Posts: 2,154
  • Kudos: 315
I AM ANGERED.
« Reply #2 on: 10 January 2003, 05:20 »
No, that's all of the code. My problem is that even though I have the "files" ".", "..", and "index.php" in my aray, it still displays ".." and "index.php".

voidmain

  • VIP
  • Member
  • ***
  • Posts: 5,605
  • Kudos: 184
    • http://voidmain.is-a-geek.net/
I AM ANGERED.
« Reply #3 on: 10 January 2003, 08:17 »
Oh, I get it now. I do this all the time but differently than you are doing it. Also use "code" tags when pasting code into a message. Keeps the format right.

First of all it looks like in your code you *want* to grab a list of files and exclude certain ones. It looks as if you "wish" to exclude "index.php" and all other "*.php" files. If that is the case, the partial answer is to change your subscripts from 1 and 4 to 0 and 3 (the first element of the array is actually 0).

When fixed this will still not exclude the "." and ".." because the "||" symbol means "or" not "through". And the 4th element (*.php) will not expand and match all PHP files, but instead would look for a single PHP file named literally '*.php'. If you'll also notice '..' *was* excluded from your list because exclude[1] is the 2nd element.

I assume that what you *really* want to do is ignore all files in your array right? I usually use the PHP grep function for this.

I'll copy/paste it into a PHP file and straighten it out for you...

[ January 09, 2003: Message edited by: void main ]

Someone please remove this account. Thanks...

voidmain

  • VIP
  • Member
  • ***
  • Posts: 5,605
  • Kudos: 184
    • http://voidmain.is-a-geek.net/
I AM ANGERED.
« Reply #4 on: 10 January 2003, 08:50 »
Here's the way I would have done it:

Code: [Select]

And of course wrap your HTML around the echo "$file" statement.
Someone please remove this account. Thanks...