English 中文(简体)
GLOB PHP的双向通道
原标题:WordPress paths with GLOB PHP

当时,我正在使用下面的法典,尝试并读出一份目录,展示所有联合项目,但因言语施压道路一米 un:

<?php 
    $path = get_bloginfo( template_directory );
    $files = glob("homepageBottomPictures/*.*");
    var_dump($files);
    for ($i=1; $i<count($files); $i++) {
        $num = $files[$i];
        echo  <img src=" .$num. " alt="random image" class="homepageBtmImg"> ."&nbsp;&nbsp;";
    } 
    echo  <div class="clearfix"></div> ;
?>

因此,在我的主题目录中,我有一个称为主页的夹。 底层 其中有JPEG的照片。 可以做些什么? (目前未退还任何款项。)

问题回答

Try using: get_theme_root() . get_template() . /homepageBottomPictures/*.* to get your directory

你可能认为这样做是有用的,我写的那部法典就是在档案名称中找到某些类型图像档案。 你们可以改变,只是 pull弃任何模式。

function returnimages($dirname, $photo_id) {

        $pattern="(^".$photo_id."[A-Za-z0-9_]*.jpg$)|(^".$photo_id."[A-Za-z0-9_]*.png$)|(^".$photo_id."[A-Za-z0-9_]*.jpeg$)|(^".$photo_id."[A-Za-z0-9_]*.gif$)"; //valid image extensions
        $files = array();
        $curimage=0;

        if($handle = opendir($dirname)) {
            while(false !== ($file = readdir($handle))){
                if(eregi($pattern, $file)){         //if this file is a matching image
                    $files[$curimage] = $dirname.$file;   //Save it in the array
                    $curimage++;
                }//end if
            }//end while

            closedir($handle);
        }//end if   
return($files);

}//end returnimages 




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签