473,236 Members | 1,628 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,236 software developers and data experts.

Appending an integer to a string

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)


Oct 7 '05 #1
2 1591
I am having problems appending a number to the end of a string. I $filename = 'test.file.";
$i = 0; and I want to change $filename to become 'test.file.0'.

$filename = "$filename$i";


$filename .= "$i";


$filename .= strval( $i );


$filename = sprintf( "%s%d", $filename, $i );


google some more...


Oct 7 '05 #2
Robizzle (Ro********@gmail.com) wrote:
: 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.";

Mismatched quotes. It works for me when I use the correct quotes.

$ php


$filename = 'test.file.'; # note quote

$filename .= $i;

echo $filename;




This programmer available for rent.
Oct 7 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: Jared | last post by:
Hello all, I'm looking for the best way to wrap my cell contents in a html label tag. The results I'm looking for will allow the user to select the checkbox when any cell in the tablerow is...
by: John A Grandy | last post by:
could someone explain the following to me : Appending the literal type character I to a literal forces it to the Integer data type. Appending the identifier type character % to any identifier...
by: Donald Grove | last post by:
Is it possible to append records to a space delimited text file, using Access 2000?
by: al jones | last post by:
Sorry, it's getting late and I'm tired. I'm trying to fill a richtect box with text derived from the array I was asking about earlier (thank you). I'm not sure what I'm seeing - since most of...
by: Jacob.Bruxer | last post by:
Hi, I want to be able to append text using a For loop to each textbox in an array of textboxes that I've created, called tBoxes(). Basically I want to add a number of spaces to each textbox in...
by: mamin | last post by:
I have a table that I need to export out to a text fiel, without column headers. I also need to have the file name include currernt date. Can anyone help me? I'm using the following code: ...
by: Thorben Grosser | last post by:
Hello Newsgroup, at the moment I am coding an archive database for a bank. Every folder has an own number, following the sheme x-x-xxx-yyyy whereas x-x-xxx describes the archive, the storage...
by: flavourofbru | last post by:
Hi, Is it possible to add an int or a string or a char to a vector variable?? For example if I declare a vector variable as follows: vector<string> abc; Can I append an integer value or some...
by: nbardach | last post by:
Hope this finds everyone well. Happy New Year! I'm trying to build a Loop for a set of dropdown menus I'm inserting into a form. Basically, the client has to be able to select 1 to 20 donors...
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.