简体   繁体   中英

How to loop thru and output values of a variant array object in Php

In my Php code I have an array object $myArrayIbject that I want to get its values. I know it is not a one dimensional array. That's what I know for sure.

When I run

echo gettype($myArrayIbject);

It returns Object.

When I run

echo count($myArrayIbject);

It returns 1632.

When I run

var_dump( $myArrayIbject);

It returns

object(variant)#3(0){ }

When I run

variant_get_type($myArrayIbject)

It returns 8209.

The other thing I have observed is that from $myArrayIbject[0] all the way to $myArrayIbject[1631] it returns integer values when I run the below code

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

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

You can use this

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM