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
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', '...
URL Checker...This function check if an url is valid or not.
function is_valid_url($url)
{
return preg_match('|^http(s)?://[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$|i', $url);
}...
UTF8 string length counter...The best way to determine the character count of a UTF8 string.
function strlen_utf8( $str )
{
return mb_strlen( $str, 'UTF-8' );
}
//or...
function strlen_utf8( $str )
{
$c = 0;...
How to created mixed arguments function...This way useful for create mixed arguments function.
function foo()
{
$args = func_get_args();
print_r($args);
}
foo(1, 1256, 6, 17); //mixed ...
-------------------Out-...