Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End Getting specific values from array

  • This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #159199
    chrisburton
    Participant

    I have an array that I need to get specific values from.

    I’m trying to list the movie titles from every key but not sure how to go about it.

    Normally I would have to do something like this:

    $trakt->activity[0]->movie->title;
    $trakt->activity[1]->movie->title;
    $trakt->activity[2]->movie->title;
    ...etc
    

    url: chrisburton.me/recently

    #159200
    __
    Participant

    The other container is an array, so you can use array indexes as normal. The inner containers are objects.

    $trakt[0]->movie->title
    $trakt[1]->movie->title
    $trakt[2]->movie->title
    …etc
    

    (or)

    foreach( $trakt as $obj ){
        $obj->movie->title;
    }
    
    #159203
    chrisburton
    Participant

    Ah ha!

    foreach( $trakt as $obj ){
      $obj->movie->title;
    }
    

    That is exactly what I was trying to do initially with a foreach but it didn’t work out. Clearly I was doing it wrong.

    Thanks, @traq

    #159288
    __
    Participant

    no problem : )

    #159349
    chrisburton
    Participant

    While I have you, can you email me so I can discuss something with you?

    Email is here.

Viewing 5 posts - 1 through 5 (of 5 total)
  • The forum ‘Back End’ is closed to new topics and replies.