public function clearIndex($dir)
    {
        $success = 0;

        if (!file_exists($dir))
        {
            $success = 1;
        }

        if (!is_dir($dir))
        {
            return @unlink($dir);
        }

        foreach (scandir($dir) as $item)
        {
            if ($item == '.' || $item == '..')
            {
                continue;
            }

            if (!$this->clearIndex($dir . DIRECTORY_SEPARATOR . $item))
            {
                $success = 0;
            }

        }

        $sucess = @rmdir($dir);

        return $sucess;
    }
public function clearIndex($dir)
    {
        $success = 0;

        if (!file_exists($dir))
        {
            $success = 1;
        }

        if (!is_dir($dir))
        {
            return @unlink($dir);
        }

        foreach (scandir($dir) as $item)
        {
            if ($item == '.' || $item == '..')
            {
                continue;
            }

            if (!$this->clearIndex($dir . DIRECTORY_SEPARATOR . $item))
            {
                $success = 0;
            }

        }

        $sucess = @rmdir($dir);

        return $sucess;
    }
public function clearIndex ( $ dir ) { $ success = 0 ; if ( ! file_exists ( $ dir ) ) { $ success = 1 ; } if ( ! is_dir ( $ dir ) ) { return @ unlink ( $ dir ) ; } foreach ( scandir ( $ dir ) as $ item ) { if ( $ item == '.' || $ item == '..' ) { continue ; } if ( ! $ this -> clearIndex ( $ dir . DIRECTORY_SEPARATOR . $ item ) ) { $ success = 0 ; } } $ sucess = @ rmdir ( $ dir ) ; return $ sucess ; }
Used to clear index folder

@param string $dir

@return number
Used to clear index folder