Hello!

I have a small script involving a while loop I'm trying to create. Here's an extract..

$vid10_title = "Sample";

$i = 10;
while ($i >= 1){

$title = "\$vid" . $i . "_title";

echo "<div>";
echo "<p><b>$title</b></p>";
echo "</div><br/>\n\n";

$i = $i - 1;
}

I want to make it so that the word "Sample" is outputted in the first instance - that is, to make $title equal to $vid10_title which then outputs that variable.

The above code outputs "$vid10_title" instead of the string "Sample".

Any ideas anyone???

Many thanks for your help.

    Change the line

    $title = "\$vid" . $i . "_title";

    to

    $title = ${"vid" . $i . "_title"};

    See Variable variables for more info

      horrah - it works... thank you very much for that reply!

        Write a Reply...