Displaying values from stdClass object

Discussion in 'Programming' started by archard, Jan 30, 2008.

  1. #1
    I'm doing some fiddling in Drupal, and I came across a function that returns this array when I print_r() it:

    Array ( [0] => stdClass Object ( [tid] => 1 [vid] => 1 [name] => Final [description] => [weight] => 0 ) )
    PHP:
    Everytime I try to print a value in this array, I get a message like this:

    
    Object of class stdClass could not be converted to string in ...common.inc(1352) : eval()'d code on line 7.
    PHP:
    So how the heck do I pull a value out of this array?
     
    archard, Jan 30, 2008 IP
  2. ro_praetor

    ro_praetor Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    
    //assuming the array is in $var
    print_r($var[0]);
    
    PHP:
    It seems that the error is somehow tied to the use of eval() . You need to tell us more of what you were trying to do.
     
    ro_praetor, Jan 31, 2008 IP