Add variable to variable name

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Boris Savc

    Add variable to variable name

    Sorry for confuzing subject, but that's the thing I'm trying to achieve. For
    example:

    $a = "Hello";
    $b = 1;

    I want to change the name of $a to $a1 where 1 is value of variable $b!

    Thanks for all the help,
    Boris


  • Rami Elomaa

    #2
    Re: Add variable to variable name

    "Boris Savc" <boris.savc@sio l.netwrote in message
    news:wf%Wh.739$ 553.591865@news .siol.net...
    Sorry for confuzing subject, but that's the thing I'm trying to achieve.
    For example:
    >
    $a = "Hello";
    $b = 1;
    >
    I want to change the name of $a to $a1 where 1 is value of variable $b!

    Insanity wrapped in perverted maddness, but...
    ${"a$b"} = $a;

    Have a nice maintenance hell.

    --
    Rami.Elomaa@gma il.com

    "Good tea. Nice house." -- Worf


    Comment

    • Toby A Inkster

      #3
      Re: Add variable to variable name

      Boris Savc wrote:
      $a = "Hello";
      $b = 1;
      >
      I want to change the name of $a to $a1 where 1 is value of variable $b!
      ${'a'.$b} = $a;
      echo $a1;

      That said, any time you're doing something like "${'a'.$b}" , alarm bells
      should be going off. You'd probably be better off using an array.

      --
      Toby A Inkster BSc (Hons) ARCS
      Fast withdrawal casino UK 2025 – Play now & cash out instantly! Discover the top sites for rapid, secure payouts with no delays.

      Geek of ~ HTML/SQL/Perl/PHP/Python*/Apache/Linux

      * = I'm getting there!

      Comment

      Working...