Sunday, 15 April 2012

PHP: Find directory by matching a pattern -



PHP: Find directory by matching a pattern -

i have little problem: want show images directory, programmed, directory has static name. how can add together here filter, or that, when send in variable osc number 31322357 it automatically find directory 31322357 - automatic board and show images? thanks.

here script:

<? //path directory scan $osc=$_get['osc']; $directory="./$osc/"; //get image files .jpg extension. $images = glob("$directory{*.jpg,*.jpg,*.png}", glob_brace); //print each file name foreach($images $image) { echo "<img src='$image' style='width:100px;height:auto'>"; } ?>

<?php ... $dirs = glob("./$osc*",glob_onlydir); $images = array(); if(count($dirs)) foreach($dirs $dir){ $images = array_merge($images,glob("$dir/{*.jpg,*.jpg,*.png}", glob_brace)); } ?>

php directory find match

No comments:

Post a Comment