我需要从以下每个STDClass对象中提取ShipQty并将其插入到新数组中。
Array ( [0] => stdClass Object ( [PRODUCTID] => 2 [ORDERID] => 7 [SHIPQTY] => 3 [STATUS] => 1 [SHIPDATE] => 2013-12-18 ) [1] => stdClass Object ( [PRODUCTID] => 2 [ORDERID] => 5 [SHIPQTY] => 2 [STATUS] => 1 [SHIPDATE] => 2014-01-02 ) [2] => stdClass Object ( [PRODUCTID] => 2 [ORDERID] => 2 [SHIPQTY] => 5 [STATUS] => 1 [SHIPDATE] => 2014-01-08 ) [3] => stdClass Object ( [PRODUCTID] => 2 [ORDERID] => 1 [SHIPQTY] => 2 [STATUS] => 1 [SHIPDATE] => 2014-01-16 ) )
我想要以下内容:array(3,2,5,2)
提前谢谢!
答案 0 :(得分:1)
试试这个(假设你的数组名为$ myArr):
$result = array();
foreach ($myArr as $obj) {
$result[] = $obj->SHIPQTY;
}
希望这有帮助。