Appending an integer to a string
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.php archive

Appending an integer to a string

From: Robizzle <Rob.Meyer1@gmail.com>
Date: Fri Oct 07 2005 - 20:44:52 CEST

I am having problems appending a number to the end of a string. I
searched google and google forums and couldn't figure it out .... sorry
i'm sure its simple.

so I have:

$filename = 'test.file.";
$i = 0;

and I want to change $filename to become 'test.file.0'.

$filename .= $i; //doesn't work
$filename += $i; //doesn't work
$filename .= (string) $i; //doesn't work, nor does += (string) $i

So, how could I do this using these variables?

(I plan to do this inside a loop, and loop until test.file.i does not
exist, at which point I will create one and save the news post. I will
do the same to display the news on my front page -- loop through
starting at i=0 and display the contents of the files until test.file.i
does not exist)

Cheers,
-Rob
Received on Tue Oct 18 02:39:01 2005