Get the first key in an object array

Discussion in 'PHP' started by archard, Mar 16, 2008.

  1. #1
    I have an array of class stdObject, which apparently makes it special. I want to get the value of the first key that comes up in that array, so I use the current() function. But I get this error:

    "recoverable fatal error: Object of class stdClass could not be converted to string"

    So any ideas how I can get the first key in this array?
     
    archard, Mar 16, 2008 IP
  2. powerspike

    powerspike Peon

    Messages:
    312
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #2
    you could try a foreach($object as $key->$value) approach.
    not sure if this is helpfull with what you are trying to do, but it's one way to do it.
     
    powerspike, Mar 16, 2008 IP