renaming

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
sublevel4
Forum Commoner
Posts: 33
Joined: Wed May 29, 2002 2:14 pm
Contact:

renaming

Post by sublevel4 »

if i have file how do i rename it but keep the same file extension
such as image.jpg -> 24039.jpg
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

Code: Select all

<?php
$filename = 'image.jpeg';
$newname = '12345'.substr($filename, strrpos($filename,'.'));
echo $newname;
?>
sublevel4
Forum Commoner
Posts: 33
Joined: Wed May 29, 2002 2:14 pm
Contact:

Post by sublevel4 »

Cool. Thanks for the help. That is exactly what i needed.
Post Reply