PHP rename.

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
lovelf
Forum Contributor
Posts: 153
Joined: Wed Nov 05, 2008 12:06 am

PHP rename.

Post by lovelf »

Code: Select all

$h1="hello";
$h2="world";
$i=1;
while($i<=2){
rename("file$i.html", "$h{$i}.php");
$i++;
}
What I'm trying to do is grab hello, and world, from $h1, and $h2, to rename file1.html, and file2.html to hello.php, and world.php

They rename to 1.php, and 2.php, what is the proper syntax to grab $h1, and $h2?
anand
Forum Commoner
Posts: 80
Joined: Fri May 22, 2009 11:07 am
Location: India
Contact:

Re: PHP rename.

Post by anand »

How about this

Code: Select all

$h1="hello";
$h2="world";
$i=1;
while($i<=2){
rename("file$i.html", "${'h' . $i}.php");
$i++;
}
Do try this once.


Sorry, if I am wrong. :oops: :oops:
lovelf
Forum Contributor
Posts: 153
Joined: Wed Nov 05, 2008 12:06 am

Re: PHP rename.

Post by lovelf »

Thank you very much, it worked awesome :drunk:
anand
Forum Commoner
Posts: 80
Joined: Fri May 22, 2009 11:07 am
Location: India
Contact:

Re: PHP rename.

Post by anand »

lovelf wrote:Thank you very much, it worked awesome :drunk:
Thanks. :)
Post Reply