Page 1 of 1

PHP rename.

Posted: Fri May 22, 2009 12:54 pm
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?

Re: PHP rename.

Posted: Fri May 22, 2009 1:21 pm
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:

Re: PHP rename.

Posted: Fri May 22, 2009 1:31 pm
by lovelf
Thank you very much, it worked awesome :drunk:

Re: PHP rename.

Posted: Fri May 22, 2009 1:35 pm
by anand
lovelf wrote:Thank you very much, it worked awesome :drunk:
Thanks. :)