0

私はこのオブジェクトを持っています:

stdClass Object
(
[daily_inventoryID] => 1
[inventory_timestamp] => 2012-06-08 14:35:42
[inventory_date] => 2012-06-08
[inventory] =>
Array
(
[0] => stdClass Object
    (
        [ingredientID] => 2
        [code] => Bf
        [description] => 1st Class Flour
        [volume] => 8268
        [price] => 750
        [amount_gram] => 0.02980
        [status] => Inactive
        [uom_id] => 1
        [flour] => Yes
    )

[1] => stdClass Object
    (
        [ingredientID] => 3
        [code] => Sf
        [description] => 3rd Class Flour
        [volume] => 18490
        [price] => 635
        [amount_gram] => 0.02540
        [status] => Inactive
        [uom_id] => 5
        [flour] => Yes
    )
...........

たとえば、オブジェクトに$ invという名前を付け、オブジェクトを含む配列である$inv->inventoryの値を表示したいとします。

foreachまたはforループを使用してそれを行うにはどうすればよいですか?

4

1 に答える 1

2
foreach ($inv->inventory as $inventory) {
  print_r($inventory);
}
于 2012-06-08T08:07:35.940 に答える