If you want to delete everything from folder (including subfolders) use this function.
function removeDir( $dir )
{
if ( is_dir( $dir ) ) {
$objects = scandir( $dir );
foreach ( $objects as $object ) {
if ( $object != "." && $object != ".." ) {
if ( filetype( $dir . "/" . $object ) == "dir" ) {
rrmdir( $dir . "/" . $object );
}
else {
unlink( $dir . "/" . $object );
}
}
}
reset( $objects );
rmdir( $dir );
}
return true;
}
removeDir( '/foo/' );Tags
No tag here. Recommended pages
File size calculator...File size calculator function return file size format into kb, mb or gb.
function file_size($size, $out = 'kb', $precision = 2)
{
switch ($out) {
case 'kb':
return round($...
Best way to get user ip address in php...Here is a function to getting ip using filter of local and lan ip's.
function get_ip()
{
$list = array( 'REMOTE_ADDR', 'CLIENT_IP', 'HTTP_CLIENT_IP',
'HTTP_PROXY_CONNECTION',...
Random string generator...Random string generator. Optionally, you can give it a desired string length.
function rnd_string($len = 24)
{
$str = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
$str...
Human readable file size...This function return formatting of file sizes in a human readable format.
function formatFileSize( $size )
{
$file_size = $size;
$i = 0;
$name = array( 'byte', 'kB', 'MB', '...