How to iterate and display the values ​​of an array object in Php

In my PHP code, I have an array object $ myArrayIbject that I want to get. I know this is not a one-dimensional array. This is what I know for sure.

When i started

echo gettype($myArrayIbject);

It returns an object.

When i started

echo count($myArrayIbject);

It returns 1632.

When i started

var_dump( $myArrayIbject);

He returns

object (option) # 3 (0) {}

When i started

variant_get_type($myArrayIbject)

It returns 8209.

Another thing I've observed is that from $ myArrayIbject [0] to the path to $ myArrayIbject [1631] it returns integer values ​​when I run the code below

for ($i=0; $i< count($myArrayIbject); $i++) {
     echo "Value at ".$i." is ". $myArrayIbject[$i]."<br/>";
}

I know that this is not a way to access all its values. I am looking for a way to extract and access all of its values.

0
source share
1 answer

You can use this

foreach($myArrayIbject as $index=>$value)
     echo "Value at ".$index." is ". $value."<br/>";
}
0
source

Source: https://habr.com/ru/post/1787854/


All Articles