2012-04-18 14 views
-2

我試圖通過從目錄中的一系列圖像以下內容ASP.NET C#PHP到ASP.NET/C#

<?php 

/* Configuration Start */ 

$thumb_directory = 'img/thumbs'; 
$orig_directory = 'img/original'; 

$stage_width=600; // How big is the area the images are scattered on 
$stage_height=400; 

/* Configuration end */ 

$allowed_types=array('jpg','jpeg','gif','png'); 
$file_parts=array(); 
$ext=''; 
$title=''; 
$i=0; 

/* Opening the thumbnail directory and looping through all the thumbs: */ 

$dir_handle = @opendir($thumb_directory) or die("There is an error with your image directory!"); 

$i=1; 
while ($file = readdir($dir_handle)) 
{ 
    /* Skipping the system files: */ 
    if($file=='.' || $file == '..') continue; 

    $file_parts = explode('.',$file); 
    $ext = strtolower(array_pop($file_parts)); 

    /* Using the file name (withouth the extension) as a image title: */ 
    $title = implode('.',$file_parts); 
    $title = htmlspecialchars($title); 

    /* If the file extension is allowed: */ 
    if(in_array($ext,$allowed_types)) 
    { 
     /* Generating random values for the position and rotation: */ 
     $left=rand(0,$stage_width); 
     $top=rand(0,400); 
     $rot = rand(-40,40); 

     if($top>$stage_height-130 && $left > $stage_width-230) 
     { 
      /* Prevent the images from hiding the drop box */ 
      $top-=120+130; 
      $left-=230; 
     } 

     /* Outputting each image: */ 

     echo ' 
     <div id="pic-'.($i++).'" class="pic" style="top:'.$top.'px;left:'.$left.'px;background:url('.$thumb_directory.'/'.$file.') no-repeat 50% 50%; -moz-transform:rotate('.$rot.'deg); -webkit-transform:rotate('.$rot.'deg);"> 
     <a class="fancybox" rel="fncbx" href="'.$orig_directory.'/'.$file.'" target="_blank">'.$title.'</a> 
     </div>'; 
    } 
} 

/* Closing the directory */ 
closedir($dir_handle); 

?> 

在ASP.NET我如何循環轉換? 在PHP中「explode」是什麼意思? 這是一個while while循環嗎?

+3

什麼是你的問題/問題? – jprofitt 2012-04-18 19:15:14

+0

oppps我忘了添加這個問題..讓我添加它..對不起一秒 – 2012-04-18 19:18:17

+1

分解:http://php.net/manual/en/function.explode.php – 2012-04-18 19:20:59

回答