database - How do I search for a specific file type using PHP's glob function? -


so, attempt @ searching .wav sound file in database using php , glob not working.

i have saved 4 sound files directory specified, when try glob, nothing back.

attempt 1:

$files = array(); foreach (glob($authorurl.'/'.$titleurl."*.wav") $file) {     $files[] = $file;     echo $file; } 

attempt 2:

$dir1 = $authorurl.'/'.$titleurl.'/'.$wordsurl; $dir = glob("$dir1/*.{wav}"); $files = scandir($dir); if(!empty($files)) {     foreach ($files $file)          print " <div class='fileicon'>                     <audio controls='controls'>                          <source src='".$dir.$file."' />                       </audio>                      <button class='button' disabled>reply</button>                     </a>                 </div>";     }  else  {     echo "there no annotations book";  } 

any appreciated! i'm not sure if i'm using right formatting glob, every time search, seems there different versions ( {}, "").

i think you're using wrong syntax glob. according the php manual, syntax of glob when using curly braces (which signifies limited alteration) demands specify special parameter

glob supports limited alternation {n1, n2, etc..}. have specify glob_brace 2nd argument glob in order work. example, if executed glob("{a,b,c}.php", glob_brace) on following list of files:

a.php b.php c.php

try executing instead, either:

$dir = glob("$dir1/*.{wav}", glob_brace); 

or

$dir = glob("$dir1/*.wav"); 

Popular posts from this blog