我的数组的 var_dump 显示如下。我想获取数组中 my_options 的计数。请注意,索引 2 没有选项。我该怎么做
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
...