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
Create directory function...Create directory if not exists.
function createDir( $dir )
{
if ( !is_dir( $dir ) ) {
mkdir( $dir, 0777 );
return true;
}
return false;
}...
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',...
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($...
SQL escape string function...Escapes special characters in a string for use in an SQL statement. howewer it check get_magic_quotes_gpc function is enable or no. if true , it strips string from slashes and escaped string from spec...