Jump to content

Archived

This topic is now archived and is closed to further replies.

DapperDanMan

Changing a filename

Recommended Posts

I have the following code to change a filename when I am creating a thumbnail on upload:
[code]
$file = "something.jpg";
$tb_image = explode(".", $file);
$array = array($tb_image[0], 'tb.jpg');
$together = implode("_", $array);
[/code]

I am curious, is there a better way than exploding the name to insert the "_tb" into the middle of the name?

DDM

Share this post


Link to post
Share on other sites
Use eregi_replace.
ex

[code]
$file = thumb.jpg
$thumbnail = eregi_replace ('.jpg', '_tb.jpg', $file);
[/code]

you can read more about eregi_replace here:
[a href=\"http://us2.php.net/eregi_replace\" target=\"_blank\"]http://us2.php.net/eregi_replace[/a]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.