问题
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.
回答1:
You can use this
foreach($myArrayIbject as $index=>$value)
echo "Value at ".$index." is ". $value."<br/>";
}
来源:https://stackoverflow.com/questions/42166123/how-to-loop-thru-and-output-values-of-a-variant-array-object-in-php