Concatenate variables

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • bettina@coaster.ch

    Concatenate variables

    I have 3 inc. files where I keep names of series in different
    languages. For example:
    $series_1 = 'kdfkd';
    $series_2 = 'fdgdgd';
    $series_3 = 'hdssasd';

    In my database I count how many different series there are (In the
    database I have different elements that belong to series). I want to
    make a link for every serie. So I use a for loop:
    for ($i = 1; $i <= $total_series; $i++) {
    ...
    ...
    <a href="paintings .php?lang=<? echo $lang?>&code_se ries=<? echo $i
    ?>" target="_blank" ><? echo $series_.$i ?></a> -> this last part is the
    problem!!!!
    }
    How can I write the reference to the serie name in the inc. file.
    That's to say, how can I concatenate $series_ and the value of $i????

    Thanks. Bettina

  • jamen

    #2
    Re: Concatenate variables

    bettina@coaster .ch wrote:[color=blue]
    > I have 3 inc. files where I keep names of series in different
    > languages. For example:
    > $series_1 = 'kdfkd';
    > $series_2 = 'fdgdgd';
    > $series_3 = 'hdssasd';[/color]
    [color=blue]
    > How can I write the reference to the serie name in the inc. file.
    > That's to say, how can I concatenate $series_ and the value of $i????[/color]

    You mean like this:

    $series_1 = 'kdfkd';
    $series_2 = 'fdgdgd';
    $series_3 = 'hdssasd';

    $i = 2;

    echo ${'series_'.$i} ; // echo 'fdgdgd'

    Comment

    • bettina@coaster.ch

      #3
      Re: Concatenate variables

      GENIAL! Thank you!!!!

      Comment

      Working...