SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict
    Join Date
    Mar 2007
    Posts
    286
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    variable variable name

    I am in a situation where I need to use one variables value as a variable name and would appreciate some help in accomplishing it. I have an object that contains a variable with the value I need
    Code:
    $object->variable
    The value of this variable is to be used as a variable name. So for instance lets say the variable above holds the value "leon" I need to be able to access $leon->something. I am using codeignitor if this helps and the variables I am referring to have been used to create result objects. So I have one query holding 10 results and I am performing a query for each result using its name field to pass into the view.

    I really hope that makes sense to someone!
    http://www.glasys.co.uk
    Noli Illegitimi Carborundum

  2. #2
    Obey the Purebreed trib4lmaniac's Avatar
    Join Date
    Dec 2004
    Location
    Cornwall, UK
    Posts
    594
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Do you mean this?
    PHP Code:
    ${$object->variable}->something

  3. #3
    SitePoint Addict
    Join Date
    Mar 2007
    Posts
    286
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes I did thanks that works great.
    http://www.glasys.co.uk
    Noli Illegitimi Carborundum


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •