concatenation of string and int in php

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tolkienarda
    Contributor
    • Dec 2006
    • 316

    concatenation of string and int in php

    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
    Code:
    //assigns classes the the corsponding class number
    $i=1;
    $classnum="void";
    $classs='class';
    while ($i<8)
    {
    	if ($row[i] = $class)
    	{
    		$classnum=$classs . $i;
    		$i=11;
    	}
    	$i++;
    }
    thanks
    eric
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    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:

    Comment

    • tolkienarda
      Contributor
      • Dec 2006
      • 316

      #3
      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

      Comment

      • ronverdonk
        Recognized Expert Specialist
        • Jul 2006
        • 4259

        #4
        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.
        Originally posted by PHP doc
        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:

        Comment

        Working...