动态多维数组对象转换为单个数组对象

时间:2017-05-15 08:33:55

标签: php arrays object

当我调用API时,我发现此数组对象“online_bill_list”对象不为我所知。请参阅详细信息。

stdClass Object
(
[online_bill_list] => stdClass Object
    (
        [tbl_bill] => stdClass Object
            (
                [id] => 2081804
                [ClientID] => 01-001-0287-00
                [holdingNo] => 01-001-0287-00
                [billno] => 01-001-0287-0032017
                [date_month] => 2017-03-01T00:00:00
                [unit] => 0.0000
                [others] => 0.0000
                [fine] => 
                [due] => 
                [bill] => 250.0000
                [netbill] => 255.0000
                [payment_date] => 2017-04-30T00:00:00
                [inserted_date] => 2017-04-18T00:00:00
        )
    )
)

我想在单个数组对象中转换此数组。

[tbl_bill] => stdClass Object
(
    [id] => 2081804
    [ClientID] => 01-001-0287-00
    [holdingNo] => 01-001-0287-00
    [billno] => 01-001-0287-0032017
    [date_month] => 2017-03-01T00:00:00
    [unit] => 0.0000
    [others] => 0.0000
    [fine] => 
    [due] => 
    [bill] => 250.0000
    [netbill] => 255.0000
    [payment_date] => 2017-04-30T00:00:00
    [inserted_date] => 2017-04-18T00:00:00

)

2 个答案:

答案 0 :(得分:1)

然后你要做的就是从更大的物体中挑选你想要的物体

$tbl_bill = $BigObject->online_bill_list->tbl_bill;

答案 1 :(得分:0)

你只需要选择你想要的对象。请尝试以下示例。

打印对象

print_r($object->online_bill_list->tbl_bill);

存储和打印对象。

$array = $object->online_bill_list->tbl_bill;
print_r($array);