Jump to content

Help interpreting print_r result...


tthdoc

Recommended Posts

I am working on modifying some code and wanted to check some variables, but am stuck on something that is probably simple, just over my head.  If I do the following:

 

print_r ($this);

 

I get this result (I used PRE tags to format it)

 

ViewList Object

(

    [_name] => list

    [_models] => Array

        (

           

  • => ModelList Object
                    (
                        [_data] => Array
                            (
                                [0] => stdClass Object
                                    (
                                        [id] => 70
                                        [catid] => 1
                                        etc......
     
    Moving down, I typed this...
     
    print_r ($this->_models);
     
    and get this...
     
    Array
    (
       
    • => ModelList Object
              (
                  [_data] => Array
                      (
                          [0] => stdClass Object
                              (
                                  [id] => 70
                                  [catid] => 1
       
      How would I get, for instance, the id?  If I try print_r($this->_models->list);  nothing happens.  In other words, if I wanted to return the id, what would it be --  $this->_models->??? .  I tried all kinds of combination's and other ways to do it, just can't figure it out.  I know it is my limited knowledge with PHP , so could someone point me in the right direction.
       
      Thanks,
      Doc

Link to comment
Share on other sites

Thanks for the quick reply, but no it does not work.  I realized when I looked at the post it stripped out some of the text.  So I am going to try to use the php tags around it. 

 

Here is the $this...

 

ViewList Object
(
    [_name] => list
    [_models] => Array
        (
            [list] => ModelList Object
                (
                    [_data] => Array
                        (
                            [0] => stdClass Object
                                (
                                    [id] => 70
                                    [catid] => 1

 

And here is the $this->models...

 

Array
(
    [list] => ModelList Object
        (
            [_data] => Array
                (
                    [0] => stdClass Object
                        (
                            [id] => 70
                            [catid] => 1

 

Hopefully it does not remove anything this time.  It is the list surrounded by brackets that is throwing me...

 

Thanks again.

Doc

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.