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

  • SEARCH
  • Home
  • 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 7443819
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:23:35+00:00 2026-05-29T11:23:35+00:00

I am having a multi dimensional array as given before with std objects as

  • 0

I am having a multi dimensional array as given before with std objects as well

    Array
(
    [0] => abc_Object Object
        (
            [_api:protected] => zvbj
            [_values:protected] => Array
                (
                    [count] => 2
                    [data] => Array
                        (
                            [0] => abc_Charge Object
                                (
                                    [_api:protected] => zvbj
                                    [_values:protected] => Array
                                        (
                                            [id] => dGoEw 
                                            [ine] => fKYF0a
                                            [xyz] => abc_Object Object
                                                (
                                                    [_api:protected] => zvbj
                                                    [_values:protected] => Array
                                                        (
                                                            [id] => uUmuym
                                                            [last] => 4242
                                                        )
                                                )
                                        )
                                )
                            [1] => abc_Charge Object
                                (
                                    [_api:protected] => zvbj
                                    [_values:protected] => Array
                                        (
                                            [id] => dblvEw 
                                            [ine] => fKyyu0a
                                            [xyz] => abc_Object Object
                                                (
                                                    [_api:protected] => z7jj
                                                    [_values:protected] => Array
                                                        (
                                                            [id] => urtuym
                                                            [last] => 4242
                                                        )
                                                )
                                        )
                                )
                        )
                )
        )
    [1] => abc_Object Object
        (
            [_api:protected] => zvbj
            [_values:protected] => Array
                (
                    [count] => 2
                    [data] => Array
                        (
                            [0] => abc_Charge Object
                                (
                                    [_api:protected] => zvbj
                                    [_values:protected] => Array
                                        (
                                            [id] => dGoEw 
                                            [ine] => fKYF0a
                                            [xyz] => abc_Object Object
                                                (
                                                    [_api:protected] => zvbj
                                                    [_values:protected] => Array
                                                        (
                                                            [id] => uUmuym
                                                            [last] => 4242
                                                        )
                                                )
                                        )
                                )
                            [1] => abc_Charge Object
                                (
                                    [_api:protected] => zvbj
                                    [_values:protected] => Array
                                        (
                                            [id] => dblvEw 
                                            [ine] => fKyyu0a
                                            [xyz] => abc_Object Object
                                                (
                                                    [_api:protected] => z7jj
                                                    [_values:protected] => Array
                                                        (
                                                            [id] => urtuym
                                                            [last] => 4242
                                                        )
                                                )
                                        )
                                )
                        )
                )
        )                       
)

I am trying to combine all these into a much simpler array as

Array(
[0]=>(
        [id] => dGoEw 
        [ine] => fKYF0a
        [cid] => uUmuym
    )
[1]=>(
        [id] => dblvEw 
        [ine] => fKyyu0a
        [cid] => urtuym
    )
[2]=>(
        [id] => dGoEw 
        [ine] => fKYF0a
        [cid] => uUmuym
    )
[3]=>(
        [id] => dblvEw 
        [ine] => fKyyu0a
        [cid] => urtuym
    )
)

I have tried alot of foreach looping and stuff but i am not able to even print first value of the array. I dont know what i am missing.

echo $arr['_api:protected'];

EDIT

foreach($arr as $key=>$val)
        {
            echo $val['_api:protected'];
            print_r($val['_values:protected']);
        }

No ouput from this even

foreach($arr as $key=>$val)
        {
            $aaa = $val['_values:protected']['data'];
            $arr111['id'] = $aaa['_values:protected']['invoice'];
            $arr111['ine'] = $aaa['_values:protected']['id'];
            $arr111['cid'] = $aaa['_values:protected']['xyz']['_values:protected']['id'];
            $arr222[] = $arr111;
        }
        print_r($arr222);

is also not giving me any output. Can anyone please tell me what i am missing?

  • 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-29T11:23:36+00:00Added an answer on May 29, 2026 at 11:23 am

    Because the properties you are trying to access are defined as protected they cannot be accessed unless you are in the context of the class of the object, or a class the extends the class of the object. The :protected that you see on the end of the key is not part of the name, it is telling you that the property is defined as protected. So the name of the key is not _values:protected, it is _values and it’s visibility is set to protected.

    Here is a slightly horrible solution with two classes that should allow you to fetch the data from a valid context:

    <?php
    
      class simplifier_Object extends abc_Object {
    
        public static function getIdFromObj ($obj) {
          return $obj->_values['id'];
        }
        public static function getDataFromObj ($obj) {
          return $obj->_values['data'];
        }
    
      }
    
      class simplifier_Charge extends abc_Charge {
    
        public static function getIdFromObj ($obj) {
          return $obj->_values['id'];
        }
        public static function getIneFromObj ($obj) {
          return $obj->_values['ine'];
        }
        public static function getXyzFromObj ($obj) {
          return $obj->_values['xyz'];
        }
    
      }
    
      // Assuming that your input array is held in $arr
    
      $result = array();
      foreach ($arr as $item) {
        foreach (simplifier_Object::getDataFromObj($item) as $sub) {
          $xyz = simplifier_Charge::getXyzFromObj($sub);
          $result[] = array (
            'id' => simplifier_Charge::getIdFromObj($sub),
            'ine' => simplifier_Charge::getIneFromObj($sub),
            'cid' => simplifier_Object::getIdFromObj($xyz)
          );
        }
      }
    
      var_dump($result);
    

    If abc_Object extends abc_Charge or vice versa, it would be possible to wrap this in a single class that extends the child object, but it still wouldn’t be a beautiful solution – someone with a better OO head than mine may have a better idea.

    As a side note, you should have error_reporting(E_ALL); ini_set('display_errors', 1); at the top of your script while developing. If you had, you would have seen many error messages with your code samples above to give you a clue what the problem is.

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

Sidebar

Related Questions

I am having issues assinging values to a multi-dimensional array. I am trying to
I have an single-dimensional array of PHP objects. Each object has two attributes, one
I'm having a problem lately that's driving me crazy. I have a multi-dimensional array
i have a multi dimension array with sub array having repeated values of '
I have the following multi-dimensional array in Ruby: [[1,2], [3], [4,5,6]] I need to
I have a multi-dimensional associative array that is encoded into JSON for database storage,
Okay, I have a multi-dimensional array which is statically-allocated. I'd very much like to
The idea I'm playing with right now is having a multi-leveled tier system of
I've got a multi-user application having some critical data of the users. I am
I'm having trouble debugging a multi-process application (specifically using a process pool in python's

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.