Dizi bulundu olanlar hariç, bir dizinin tüm görüntüleri listelemek [image1.jpg, image2.jpg, vb]

0 Cevap php

Aşağıdaki 2 kod şube dizininde bulunan tüm görüntüleri ($ dir) verir.

Ben sadece aşağıdaki $ excludeImages dizide görünen çıkışı herhangi bir görüntü dışlamak istiyorum:

    /* collect attached images into an array to test against */
    global $wpdb;
    $excludeImages = array();
    $excludeImagesFiles = $wpdb->query(
        "SELECT meta_value 
         FROM $wpdb->postmeta WHERE meta_key = '_wp_attached_file'");
    array_push($excludeImages, $excludeImagesFiles);

Bu dışlama filtresi olmadan var gibi bu kodu ...

    $imgs = array();
    if ($dh = opendir($dir)) 
    {
    if(!get_option('cb2_underscores')){$myfilter="^";}else{$myfilter="";}

    while (($file = readdir($dh)) !== false) 
        {
        if (!is_dir($file)&& $file != "." && $file != ".." && preg_match("/^[".$myfilter."_].*\.(bmp|jpeg|gif|png|jpg)$/i", $file))
        // and $file not contained in the $excludeImagesFiles array
            {
                array_push($imgs, $file);
            }
        }
        closedir($dh);
    } else {
        die('cannot open ' . $dir);
    }
    if($imgs) 
    {
        sort($imgs); 
        echo '<div class="images">';
        foreach ($imgs as $idx=>$img) 
        {
            $class = ($idx == count($imgs) - 1 ? ' class="last"' : '');
            echo $prelink.' src="' . $url . $img . '" alt="' .$img . '"' . $class . ' />'.$postlink;
        }
        echo '</div>';
    }

Ne kod Ben dizi resimlerin herhangi (array_push eklenen alamadım emin olmak için ise şube eklemek gerekiyor)?

0 Cevap