Originally posted by devinemke
$filename = 'foo.txt';
echo basename($filename, '.txt'); // outputs "foo"
[/B]
Sure, but suppose we have a list of files like:
foo.txt
bar.gif
baz.exe
qux.file
quux.c
garply.this.is.a.long.unix.thing.here
We'd have to parse the filename somehow in order to get a suffix to feed to basename, so you end up using strtok or substr or something anyway ...
explode's pretty easy. The canonical algorithm would be a lil' more like what limeonade has already done in the function ...
... like I said, "smart newbie!"
BTW, I'm just kidding there ... nothing personal. 🙂