任何人帮助我将stdClass对象转换为php中的数组

时间:2016-03-11 08:15:13

标签: php

      stdClass Object ( [Order] => stdClass Object 
    ( [id] => c62f5d272ghjjgd346lmn34 
    [type] => [status] => placed 
    [keys_status] => Keys were generated )
 [Products] => Array ( [0] => stdClass Object ( [name] => Mobile Security 
[devices] => 1 [months] => 12 [quantity] => 1 [msrp_price] => 9 [discount] => 0.0 [end_user_price] => 9 [reseller_margin] => 0.0 [reseller_price] => 9.01[partner_margin] => 90 [partner_price] => 0.9[Keys] => Array ( [0] => stdClass Object ( [product_id] => 21 [product_name] => Mobile Security [key] => 1234) ) ) ) [Customer] => stdClass Object ( [name] => IPPS [phone] => 25667587576 [address] => Bishop willis Street [contact_person] => Mukama Gordon [city] => Kigali [zipcode] => 250 [country_id] => 202 [state_id] => [email] => mukamatest@test.com ) [Keys] => Array ( [0] => stdClass Object ( [product_id] => 21 [product_name] => Mobile Security [key] => 1234 ) ) )

1 个答案:

答案 0 :(得分:1)

这是一种真正的hacky方式,但尝试

$arrayversion = json_decode(json_encode($objectversion), true);

然后

print_r($arrayversion);将是一个数组。