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 7928203
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T19:40:34+00:00 2026-06-03T19:40:34+00:00

How can I call methods from an array of objects (that hold an array

  • 0

How can I call methods from an array of objects (that hold an array of objects). I read: Get array with results of object method on each item in an array of objects in PHP but could not get it.

Here is my testcode: the first object holds attributes, then an object holds a record of the multiple attributes.

/*--------------------------------- */
class SqliteAttribute {

    private $_fieldname = '';
    private $_fieldvalue = '';
    private $_type = 'TEXT';
    private $_key = true;

    function __construct($fieldname, $fieldvalue, $text, $key) {
        $this->_fieldname  = $fieldname;
        $this->_fieldvalue = $fieldvalue;
        $this->_text       = $text;
        $this->_key        = $key;
    }

    function AsArray() {
        $tempArray = array('fieldname'     => $this->_fieldname,
                           'fieldvalue'    => $this->_fieldvalue,
                           'type'          => $this->_type,
                           'key'           => $this->_key
        );
        return $tempArray;
    }
}

/*--------------------------------- */
class SqliteRecord {

    private $_attributes = array();

    function __construct() {
    }

    function AddAttribute($fieldname, $fieldvalue, $text, $key) {
        $attribute          = new SqliteAttribute($fieldname, $fieldvalue, $text, $key);
        $this->attributes[] = $attribute;
        var_dump($this->_attributes); // shows it!
    }

    function AsArray() {
        $temp_array = array();
        var_dump($this->_attributes); // shows nothing
        foreach ($this->_attributes as $key => $value) {
            $temp_array[] = $value->AsArray();
        }
        return $temp_array;
    }

}

And I call it like this

function updateFiles($files, $rootpath) {
    $recordset = new SqliteRecordSet;
    foreach ($files as $file) {
        $record = new SqliteRecord;
        $record->AddAttribute('Path', $file[0], 'TEXT', true);

        print_r($record->AsArray()); // shows nothing       
    }

    $recordset->insertIfNotExist_index();
}
  • 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-06-03T19:40:35+00:00Added an answer on June 3, 2026 at 7:40 pm

    $this->attributes vs $this->_attributes

    you should always develop code with error reporting set to E_ALL and display_errors on. php would have notified you of your mistake here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to call some methods in Wininet.dll from a Java program. I can
Can I call public method from within private one: var myObject = function() {
Can one call a method from another model in a model in CodeIgniter? I
how can I call a method from another class and not be restriced to
In iOS, how can I call an Objective-C method from Javascript in a UIWebView
I can't figure out how to call a base class method from a derived
In Python, how can I print the current call stack from within a method
How to create a generic method which can call overloaded methods? I tried but
I've read that an object can only have one delegate at once. But is
Can we call COM exposed interface methods at runtime one by one? This can

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.