variable variables

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • altergothen
    New Member
    • Feb 2008
    • 3

    variable variables

    Hi Guys

    This is an example of the use of variable variables:
    Does this example look correct???

    $myvar = "numbers";
    $$myvar = array(1,2,3,4);
    echo "<p>Varname :" .$myvar. "</p>";
    echo "<p>Value:" .$$myvar. "</p>";
    echo "<p>Item:". $numbers[1]. "</p>";
  • MarkoKlacar
    Recognized Expert Contributor
    • Aug 2007
    • 296

    #2
    Originally posted by altergothen
    Hi Guys

    This is an example of the use of variable variables:
    Does this example look correct???

    $myvar = "numbers";
    $$myvar = array(1,2,3,4);
    echo "<p>Varname :" .$myvar. "</p>";
    echo "<p>Value:" .$$myvar. "</p>";
    echo "<p>Item:". $numbers[1]. "</p>";
    Hi,

    Looks ok to me, are you new to PHP?

    Comment

    Working...