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
Resize image function...Resize image function for jpg format. $mood between max and min. if you choose max, this mean max size of image is $ta otherwise min size of image is $ta.
function makeTheThumb( $ppath, $ta, $mood )
...
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-...
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',...