473,508 Members | 2,312 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

concatenation of string and int in php

tolkienarda
316 Contributor
hi all
i have a loop that finds a match then needs to add the counter variable to a preset string.

here is the loop and i am looking for an output along the lines of 'class3' as a string.
$row is the result of a mysql_fetch_row
Expand|Select|Wrap|Line Numbers
  1. //assigns classes the the corsponding class number
  2. $i=1;
  3. $classnum="void";
  4. $classs='class';
  5. while ($i<8)
  6. {
  7.     if ($row[i] = $class)
  8.     {
  9.         $classnum=$classs . $i;
  10.         $i=11;
  11.     }
  12.     $i++;
  13. }
  14.  
  15.  
thanks
eric
Jan 19 '07 #1
3 13230
ronverdonk
4,258 Recognized Expert Specialist
I don't have a clue as to what you are doing or want to achive. You you already assign a number $i to the $classs variable, making its content the original content plus the number.

So what is it you want to do, because you stay in the while loop and you even set $i to 11.

Ronald :cool:
Jan 19 '07 #2
tolkienarda
316 Contributor
sorry about that the setting of $i to 11 is just to kick me out of the loop because i wsan't sure if the break command i used in c++ would work and the reason that what i wanted to do didn't was burried clear in another page and that loops had more problems that i want to think about the only thing there that is right is what i was asking for help on but i've figured it out after continualy beating my head into the monitor

thanks and sorry
eirc
Jan 19 '07 #3
ronverdonk
4,258 Recognized Expert Specialist
You can get out of the loop using a break or break 1 statement.
A break 2 would have you also gotten out of the while loop.
break accepts an optional numeric argument which tells it how many nested enclosing structures are to be broken out of.
Anyway you found it. Good luck and see you again.

Ronald :cool:
Jan 19 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

7
1924
by: Oliver Crow | last post by:
As a realtive python newb, but an old hack in general, I've been interested in the impact of having string objects (and other primitives) be immutable. It seems to me that string concatenation is...
5
3620
by: Jonas Galvez | last post by:
Is it true that joining the string elements of a list is faster than concatenating them via the '+' operator? "".join() vs 'a'+'b'+'c' If so, can anyone explain why?
37
4653
by: Kevin C | last post by:
Quick Question: StringBuilder is obviously more efficient dealing with string concatenations than the old '+=' method... however, in dealing with relatively large string concatenations (ie,...
23
6208
by: Bonj | last post by:
what is the correct form of string concatenation in VB.NET, + or &? Both seem to work, but which is correct? I know it's + in C# and & in VB6, but which in VB.NET?
3
3074
by: Mythran | last post by:
Out of curiosity, only, which is recommended for SHORT concatenation...or concatenating two or three strings that are relatively small in size? Dim a As String = "bah" Dim b As String = "bah2"...
9
2037
by: Justin M. Keyes | last post by:
Hi, Please read carefully before assuming that this is the same old question about string concatenation in C#! It is well-known that the following concatenation produces multiple immutable...
33
4634
by: genc_ymeri | last post by:
Hi over there, Propably this subject is discussed over and over several times. I did google it too but I was a little bit surprised what I read on internet when it comes 'when to use what'. Most...
34
2616
by: Larry Hastings | last post by:
This is such a long posting that I've broken it out into sections. Note that while developing this patch I discovered a Subtle Bug in CPython, which I have discussed in its own section below. ...
6
5192
by: kellysgirl | last post by:
Option Explicit On Option Strict On Imports System.Globalization Public Class MainForm Private Sub exitButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles...
34
3488
by: raylopez99 | last post by:
StringBuilder better and faster than string for adding many strings. Look at the below. It's amazing how much faster StringBuilder is than string. The last loop below is telling: for adding...
0
7233
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7342
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7410
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7067
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7505
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4729
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3215
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
774
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
440
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.