php - Display all file with prefix id -


i have user folder /folder_name , there files name prefix example pattern id_radom.example

5__1490952185fed525d92.24525311.jpg 15__4658521860030a66d0.90328377.jpg 15__6654521861778060e1.31100475.jpg 15__6654521861778060e1.31100475.jpg 

i want display of these image(id=15) using php

i trying:

$path = "uploads/registered_files/".$_session['user_data']['username']; $a = glob("/".$path."/".$article->article_id."__",glob_brace); print_r($a); 

but got empty array()

solution may this:

if (false === ($handle = opendir($path))) {     //catch error here }  $images = array(); while (false !== ($file = readdir($handle))) {     preg_match('/^15__.*/', $file)) , $images[] = $file; } closedir($handle);  foreach ($images $image) {     echo '<img src="',$path,directory_separator,$image,'"/>'; } 

Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -