开发者

delete all files in a folder with php [duplicate]

This question already has answers here: Closed 12 years ago.

Possible Duplicate:

how to delete a folder with contents using PHP

hi,

is it possible to delete all children within a parent directory and then delete the the parent directory in php?

Edited:

When i use scan dir why does the first 2 elements of the a开发者_JAVA百科rray show '.', '..'?:

> Array ( [0] => . [1] => .. [2] => evga-nvidia-graphics-card4d0fe6868d2f8.jpg [3] => image4d0eaafb920a0.png [4] => image4d0eab086a106.png ) 

many thanks


The first elements in your array (. and ..) are references to the directory itself (.) and to its parent directory (..). Every non-root directory in your filesystem will have both of them. They are usually ignored by hand in this kind of scripts.

If you use a DirectoryIterator you can tell if the current element you're iterating over is either . or .. with the isDot() function.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜