SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot Koobi's Avatar
    Join Date
    Nov 2003
    Location
    Sri Lanka
    Posts
    156
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How do I access the object in this array?

    How would I echo the seat_id or user_id?

    PHP Code:
    Zend_View Object
    (
     [
    0] => stdClass Object
            
    (
                [
    seat_id] => 1
                
    [user_id] => 15
            
    )
        [
    button] => Update
        
    [id] => booking-edit
        
    [name] => booking-edit
        
    [method] => put

    That is the output of a print_r() of $this within the scope of a class.

    $this->0
    and
    $this->[0]
    won't work because they are syntactically incorrect.

    Do I have to use and SPL iterator for this?

    Thanks.

  2. #2
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2008
    Posts
    5,757
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    $this->{0}

    Other choices are to use ArrayIterator, or get_object_vars()

  3. #3
    SitePoint Wizard PHPycho's Avatar
    Join Date
    Dec 2005
    Posts
    1,201
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you are looping then simply use as:
    PHP Code:
    foreach($zend_view_object as $obj){
    if(
    is_object($obj)){
     
    $obj->seat_id;
     
    $obj->user)id;
    }



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
  •