Trying to reduce alot of my codes size and am having no joy with this
code. How can I get this smaller?
// Block
$prefix_length = strlen( PREFIX_BLOCKS );
$block_dir = @opendir($root_path . 'modules/modules_blocks');
while( false !== ($dir_name = readdir($block_dir)) )
{
if( $dir_name != "." && $dir_name != ".." )
{
if ( substr( $dir_name, 0, $prefix_length ) == PREFIX_BLOCKS
)
{
if( is_dir( $root_path . 'modules/modules_blocks/' .
$dir_name))
{
$mod_list_blocks[] = $dir_name;
}
}
}
}
@closedir( $block_dir );
// Page
$prefix_length = strlen( PREFIX_PAGES );
$page_dir = @opendir($root_path . 'modules/modules_page');
while( false !== ($dir_name = readdir($page_dir)) )
{
if( $dir_name != "." && $dir_name != ".." )
{
if ( substr( $dir_name, 0, $prefix_length ) == PREFIX_PAGES
)
{
if( is_dir( $root_path . 'modules/modules_page/' .
$dir_name))
{
$mod_list_page[] = $dir_name;
}
}
}
}
@closedir( $page_dir );
// Admin
$prefix_length = strlen( PREFIX_ADMIN );
$admin_dir = @opendir($root_path . 'modules/modules_admin');
while( false !== ($dir_name = readdir($page_dir)) )
{
if( $dir_name != "." && $dir_name != ".." )
{
if ( substr( $dir_name, 0, $prefix_length ) == PREFIX_ADMIN
)
{
if( is_dir( $root_path . 'modules/modules_admin/' .
$dir_name))
{
$mod_list_admin[] = $dir_name;
}
}
}
}
@closedir( $admin_dir );
big thanks