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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T00:21:05+00:00 2026-06-09T00:21:05+00:00

var_dump of my array shows up like this. I want to get the count

  • 0

var_dump of my array shows up like this. I want to get the count of my_options in the array. note that index 2 has no options. How’ I go about doing that

var_dump($myVar);


array
  0 => 
    object(app\models\Product)[209]
      protected '_Nested' => 
        array
          empty
      protected '_Sibling' => 
        array
          empty
      protected '_class' => string 'app\models\Customer' (length=18)
      protected '_data' => 
        array
          '_id' => int 345543
          'customer_name' => string 'John Dee' (length=14)
          'Sibling' => 
            array
              ...
          'my_options' => 
            array
              ...
          'Nesting' => 
            array
              ...
          'image' => string 'img.jpg' (length=35)
          'inventory' => 
            array
              ...
          'name' => string 'papa john' (length=35)
          'price' => float 26
          'status' => int 1
1 => 
    object(app\models\Product)[209]
      protected '_Nested' => 
        array
          empty
      protected '_Sibling' => 
        array
          empty
      protected '_class' => string 'app\models\Customer' (length=18)
      protected '_data' => 
        array
          '_id' => int 89237
          'customer_name' => string 'Linda Arap' (length=14)
          'Sibling' => 
            array
              ...
          'my_options' => 
            array
              ...
          'Nesting' => 
            array
              ...
          'image' => string 'img2.jpg' (length=35)
          'inventory' => 
            array
              ...
          'name' => string 'Pizza Hut' (length=35)
          'price' => float 26
          'status' => int 1
2 => 
    object(app\models\Product)[209]
      protected '_Nested' => 
        array
          empty
      protected '_Sibling' => 
        array
          empty
      protected '_class' => string 'app\models\Customer' (length=18)
      protected '_data' => 
        array
          '_id' => int 89237
          'customer_name' => string 'Linda Arap' (length=14)
          'Sibling' => 
            array
              ...
  • 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-09T00:21:07+00:00Added an answer on June 9, 2026 at 12:21 am

    _data is a protected variable so you won’t be able to access it from outside the object. You’ll need to use (or create) a getData() method that accesses$this->_data. Just call that method and you’ll have access to the options array.

    Example method that accesses _data and returns my_options all in one:

    public function getMyOptions() {
      return $this->_data['my_options'];
    }
    

    Which can be invoked with something like:

    $product instanceof app\models\Product;
    $myOptions = $product->getMyOptions();
    

    Also, it looks like you’re using a model (possibly orm) class. I would imagine it has built-in methods to access the data array. Common methods to access my_options would be:

    $options = $product->my_options; // via magic methods
    $options = $product->get('my_options');
    $options = $product->getField('my_options');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this array called $addon_array , that when i use var_dump shows up
My var_dump($gallery) looks like this: array(1) { [0]=> object(stdClass)#102 (9) { [term_id]=> string(2) 17
I need a function like var_dump($object) in php The problem is that the Var_dump
I have an array in the database and it looks like this: {hello:world, Test:[hello]}
The following code shows that fields like datetime, float and decimal in my test
When I dump my the varable var_dump($search_results_returned['post_q_2_full']); the following is printed: array(1) { [0]=>
Here is the result of var_dump($my_var[id]) on the object I'm having issues with: array(1)
$arr = array(array(array())); foreach($arr as $subarr) { $subarr[] = 1; } var_dump($arr); Output: array(1)
$arrayIter = new ArrayIterator( array(1, 2) ); $iterIter = new IteratorIterator($arrayIter); var_dump($iterIter->valid()); //false var_dump($arrayIter->valid());
Let's see if I can describe this properly... I have an abstract class that

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.