Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6094147
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:38:36+00:00 2026-05-23T12:38:36+00:00

I have a variable that is an array in Smarty, and I am trying

  • 0

I have a variable that is an array in Smarty, and I am trying to figure out how to retrieve that information. The variable is called $COMMENTS and I did $COMMENTS|@print_r and this is what I got:

Array ( 
    [0] => ModComments_CommentsModel Object ( 
        [data:private] => Array ( 
            [0] => 11686 
            [crmid] => 11686 
            [1] => 1679 
            [smcreatorid] => 1679 
            [2] => 1679 
            [smownerid] => 1679 
            [3] => 0 
            [modifiedby] => 0 
            [4] => ModComments 
            [setype] => ModComments 
            [5] => 
            [description] => 
            [6] => 2011-06-08 15:00:31 
            [createdtime] => 2011-06-08 15:00:31 
            [7] => 2011-06-08 15:00:31 
            [modifiedtime] => 2011-06-08 15:00:31 
            [8] => 2011-06-29 12:00:23 
            [viewedtime] => 2011-06-29 12:00:23 
            [9] => 
            [status] => 
            [10] => 0 
            [version] => 0 
            [11] => 1 
            [presence] => 1 
            [12] => 0 
            [deleted] => 0 
            [13] => 11686 
            [modcommentsid] => 11686 
            [14] => aasd 
            [commentcontent] => aasd 
            [15] => 6730 
            [related_to] => 6730 
            [16] => 
            [parent_comments] => 
            [17] => 11686 
        )
    )
    [1] => ModComments_CommentsModel Object ( 
        [data:private] => Array ( 
            [0] => 11685 
            [crmid] => 11685 
            [1] => 1679 
            [smcreatorid] => 1679 
            [2] => 1679 
            [smownerid] => 1679 
            [3] => 0 
            [modifiedby] => 0 
            [4] => ModComments 
            [setype] => ModComments 
            [5] => 
            [description] => 
            [6] => 2011-06-08 14:58:42 
            [createdtime] => 2011-06-08 14:58:42 
            [7] => 2011-06-08 14:58:42 
            [modifiedtime] => 2011-06-08 14:58:42 
            [8] => 
            [viewedtime] => 
            [9] => 
            [status] => 
            [10] => 0 
            [version] => 0 
            [11] => 1 
            [presence] => 1 
            [12] => 0 
            [deleted] => 0 
            [13] => 11685 
            [modcommentsid] => 11685 
            [14] => comment 
            [commentcontent] => comment 
            [15] => 6730 
            [related_to] => 6730 
            [16] => 
            [parent_comments] => 
            [17] => 11685
        )
    )
    [2] => ModComments_CommentsModel Object ( 
        [data:private] => Array ( 
            [0] => 6731 
            [crmid] => 6731 
            [1] => 1679 
            [smcreatorid] => 1679 
            [2] => 1679 
            [smownerid] => 1679 
            [3] => 0 
            [modifiedby] => 0 
            [4] => ModComments 
            [setype] => ModComments 
            [5] => 
            [description] => 
            [6] => 2010-11-02 10:15:06 
            [createdtime] => 2010-11-02 10:15:06 
            [7] => 2010-11-02 10:15:06 
            [modifiedtime] => 2010-11-02 10:15:06 
            [8] => 
            [viewedtime] => 
            [9] => 
            [status] => 
            [10] => 0 
            [version] => 0 
            [11] => 1 
            [presence] => 1 
            [12] => 0 
            [deleted] => 0 
            [13] => 6731 
            [modcommentsid] => 6731 
            [14] => Test comment 
            [commentcontent] => Test comment 
            [15] => 6730 
            [related_to] => 6730 
            [16] => 
            [parent_comments] => 
            [17] => 6731
        ) 
    )
)

I am trying to retrieve the 11686 number from that. Any help? I have tried $COMMENTS[0][data:private][0] but that didn’t work.

Any help greatly appreciated 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T12:38:37+00:00Added an answer on May 23, 2026 at 12:38 pm

    First, put print_r() output into <pre> tags so it is readable.

    Array ( 
        [0] => ModComments_CommentsModel Object ( 
            [data:private] => Array ( 
                [0] => 11686 
                [crmid] => 11686 
                [1] => 1679 
                [smcreatorid] => 1679 
                [2] => 1679 
                ...
            )
        )
        ...
    )
    

    You’re trying to access the first object in your array, $COMMENTS[0]. Since that it is object, and your data property is private, you cannot access it in Smarty. You would have to edit the ModComments_CommentsModel class to give you access to either the data property or the crmid key of the property.

    Example:

    class ModComments_CommentsModel {
    
        // ...
    
        public function CrmId(){
            return $this->data['crmid'];
        }
    
        // ...
    
    }
    

    {* template *}
    {$COMMENTS[0]->CrmId()}
    
    {* might have to assign before using method call *}
    {assign var='comment' value=$COMMENTS[0]}
    {$comment->CrmId()}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a variable that I got out of the database table like this:
I have a variable that contains : Sometimes array of strings and sometimes array
I have a recursion function that parses an object/array with a global variable. If
I have a variable that contains a 4 byte, network-order IPv4 address (this was
I have a variable that has this string: <DIV><SPAN style=FONT-FAMILY: Tahoma; FONT-SIZE: 10pt>[If the
I have a variable that looks likes this, $rslt['expected_salary_level'] This returns a string similar
I have a variable, $var , that contains a string of characters, this is
I have a variable length array that I need to transpose into a list
I've been trying to figure this one out for a bit... I even downloaded
I have a variable that contains an array. That array contains X number of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.