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;...
Validate phone number...Chek if a phone numbers is valid, according to its syntax (should be: "+390523599314"). True if it's valid, False otherwise
function is_valid_phone( $phone )
{
if ( $phone[0] != "+" ) {
...
Email Address Checker...This function check if an e-mail address is valid or not.
function valid_email($email)
{
return preg_match('/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/',
$email);...