有人帮我把标准类对象转换为 PHP 中的数组


anyone to help me convert stdClass Object to an array in 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 ) ) )

这是一种非常笨拙的方法,但请尝试

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

然后

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