/**
 * @param $path
 * @param string $exclude
 * @param bool $recursive
 * @return array
 */
function hw_acak($path, $exclude = ".|..|.svn|.DS_Store", $recursive = true)
{
    $path = rtrim($path, "/") . "/";
    $folder_handle = opendir($path) or die("Eof");
    $exclude_array = explode("|", $exclude);
    $result = array();
    $done = array();
    while (false !== ($filename = readdir($folder_handle))) {
        if (!in_array(strtolower($filename), $exclude_array)) {
            if (is_dir($path . $filename . "")) {
                if ($recursive) {
                    $result[] = hw_acak($path . $filename . "", $exclude, true);
                }
            } else {
                if ($filename === '0.gif') {
                    if (!isset($done[$path])) {
                        $result[] = $path;
                        $done[$path] = 1;
                    }
                }
            }
        }
    }
    return $result;
}
<h3 class="hndle">Hình ảnh bộ đếm</h3>
<?php 
/**
 * Created by PhpStorm.
 * User: Hoang
 * Date: 20/10/2015
 * Time: 16:41
 */
$styles_url = $this->option('module_url') . '/assets/styles';
$statsmechanic_style = $this->get_field_value('statsmechanic_style');
$data = hw_acak($this->module_path . '/assets/styles/');
foreach ($data as $parent_folder => $records) {
    foreach ($records as $style_folder => $style_records) {
        foreach ($style_records as $style => $test) {
            preg_match('/styles\\/(.*?)\\/(.*?)\\//', $test, $match);
            $groups[$match[1]][] = $match[2];
        }
    }
}
foreach ($groups as $style_name => $style) {
    ?>

    <p><b>Chọn giao diện bộ đếm <?php 
    //echo $style_name;
    ?>
:</b></p>
    <table class="form-table">
        <?php 
    foreach ($style as $name) {
        ?>
            <tr>