Re: [PHP] Show filenames using Wildcards -- The glob() Solution!



On 3/30/07, Rahul Sitaram Johari <sleepwalker@xxxxxxxxxxxxxxxx> wrote:
Ave,

This Works!!!

<?php
foreach (glob("vox/".$row['PHONE']."*.vox") as $value) {
echo "<OPTION
VALUE='takekey_download.php?F=vox/".basename($value)."'>".basename($value)."
</option>";
}
?>

Dug up glob() in the manual, followed examples and details ­ works like a
charm!
Full code:

<SCRIPT LANGUAGE="JavaScript">
function openVox(form) {
var newIndex = form.voxSelect.selectedIndex;
if (newIndex == 0) {
//alert( "Please select a file to download!" );
} else {
dlvox = form.voxSelect.options[newIndex].value;
window.location.assign(dlvox);
}
}
</SCRIPT>
<FORM NAME="voxForm" STYLE="margin: 0px; padding: 0px;">
<SELECT NAME="voxSelect" onChange="openVox(this.form)">
<OPTION>... Choose Recording ...</OPTION>
<?php
foreach (glob("vox/".$row['PHONE']."*.vox") as $value) {
echo "<OPTION
VALUE='takekey_download.php?F=vox/".basename($value)."'>".basename($value)."
</option>";
}
?>
</SELECT>
</FORM>

Thanks!

I see you're using glob now, but I found this comment in your other thread:
"Yes, and while I dig up on glob(), to be quite honest, the exec is working
very effectively and fast for my searches & download application - so can't
complain about it one bit."

I didn't test both myself, but you might want to see the difference in
performance.

Tijnema

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Rahul Sitaram Johari
CEO, Twenty Four Seventy Nine Inc.

W: http://www.rahulsjohari.com
E: sleepwalker@xxxxxxxxxxxxxxxx

³I morti non sono piu soli ... The dead are no longer lonely²

.



Relevant Pages