PHP question - grabbing a file with a lower case extension...

Hi, I realize this may not be the best message board for this question, so if you know of a better one please let me know…

Here’s my problem - I’m trying to grab a .wav file and make an MP3 out of it using the program sox. However, the directory which has the .wav files also has .WAV files. A .WAV file is MS wav format, gsm encoded (wav49) and is encoded differently than .wav file which is MS wav format, 16 bit linear.

Anyway, what I want to grab is the .wav file and it’s grabbing the WAV file. The code is below. I tried changing the second line to

$wav = $fl[0].”.WAV”;

but that didn’t do it. I don’t really know PHP - I’m just modifying someone else’s code. Does anyone know what I need to do to grab the right file or a different message board where I should post my question? Thanks.

function getMP3File($d, $file, $props, $device, $mailbox, $vm_config, $vm_name, $context) {

$fl = split(“.”,$file);
$wav = $fl[0].“.wav”;
$uid = $fl[0].“.”.sha1($props[‘origtime’]. $props[‘callerchan’].$props[‘duration’]);
$mp3 = $uid.‘.mp3’;

if (!file_exists($d . $mp3)) {//generate mp3 file if it doesn’t exist
$cid = getCallerIDArray($props[‘callerid’]);
$title = ’ --tt “Message from ‘. $cid[0]. ’ ph# ’ . $cid[1] .’”‘;
$artist = ’ --ta "’. $cid[0].‘"’;
$album = ’ --tl “'. $vm_config[$context][$device][1] . ‘'s mailbox ’ . $mailbox .’ at ’ . $vm_name . '”‘;
$comment = ’ --tc “Generated by LifeOnRecord Feeder http://www.LifeOnRecord.com”’;
system(‘/usr/bin/lame -h --nspsytune --athtype 2 --lowpass 11 --ns-bass -8 --scale 0.93 --cbr -b 96 --resample 22.05 --add-id3v2’ . $title . $artist . $album . $comment . ’ ’ . $d . $wav . ’ ’ . $d . $mp3 .’ &');
}
return $uid;
}

One piece of information I should have mentioned is that the PHP code is running on a Linux server.

I’m no PHP expert but if I was doing this in ASP I would make sure the strings always match by making the requested string and the matching string uppercase. Looks like you need to use str_to_upper.

So…WAV would always match str_to_upper($str) no matter if it’s stored on the server as WAV or wav.

Someone else with more skillz might come along and give you specific help for your func, but you can chew on that for a while.

Yeah my bad…it’s strtoupper() not str_to_upper.

Carry on.

Thanks Zipper. I’m confused as to how that would help me…

In the directory the script is reading there are files like this:

msg0014.WAV
msg0014.wav
msg0013.WAV
msg0013.wav

If I always want to grab the .WAV files, and I use strtoupper() then won’t the .wav files look like WAV files and and I won’t be able to differentiate anymore? Or am I missing something? I guess the problem is that the files have the same name except for the case, and I always want to grab the file with the upper case extension.

Thanks.