Think about it logically for a minute (y'know, like a programmer would).
You have to use it before you make the decision about which icon to use.
It has to make this decision by looking at the value of $file.
You probably don't want to waste its time with things like "." and "..".
You have to do one thing if it returns true, and something else if it returns false.
(PHP has a syntax construct for this).
If it returns true, meaning that $file is a directory, you want to return (oh all right, output) a "folder" icon.
Otherwise ("else") you want to output an icon depending on what the file extension is.