1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | // ディレクトリを指定。省略時は topというディレクトリ function randjpg( $tagdir = 'top' ) { if ( $dh = opendir( $tagdir )) { $i = 0; while ( $file = readdir( $dh )) { if (preg_match ( '/.jpg$/' , $file )) { $pict [ $i ++] = $file ; } } closedir ( $dh ); $tag = $tagdir . '/' . $pict [rand(0, $i - 1)]; print "<img src=\"{$tag}\" alt=\"\" />" ; } else { print "directory open error\n" ; } } |
今見ると適当すぎる...
0 件のコメント:
コメントを投稿