Add to a Simple XML Object

I need someone to quickly solve this problem and tell me whats being done wrong. First solution gets paid. I need to add additional products to the $products object using the $fields array to set the key/values. This job will pay $15. It should be very quick for someone who knows just a little more than me.

When using the code below to add a product to the $products SimpleXML object I get an error Warning: Illegal offset type in file and can't figure out what is wrong.

$fields = array(

$o->order_id => 'order_id',

$o->order_address_id => 'order_address_id',

$o->price_ex_tax => 'price_ex_tax' ,

'DISCS' => 'sku',

'1' => 'quantity'



array_walk_recursive($fields, array ($products, 'addChild'));

HERE IS MY SIMPLEXML OBJECT using print_r for $products:

SimpleXMLElement Object


[product] => Array


[0] => SimpleXMLElement Object


[id] => 23

[order_id] => 110

[product_id] => 63477

[order_address_id] => 11

[name] => Dead Sea Treasures Foot Cream

[sku] => 703

[type] => physical

[base_price] => 20.0000

[price_ex_tax] => 20.0000

[price_inc_tax] => 20.0000

[price_tax] => 0.0000

[base_total] => 40.0000

[total_ex_tax] => 40.0000

[total_inc_tax] => 40.0000

[total_tax] => 0.0000

[weight] => 0.5

[quantity] => 2

[base_cost_price] => 0.0000

[cost_price_inc_tax] => 0.0000

[cost_price_ex_tax] => 0.0000

[cost_price_tax] => 0.0000

[is_refunded] => false

[refund_amount] => 0.0000

[return_id] => 0

[wrapping_name] => SimpleXMLElement Object



Kemahiran: PHP

Lihat lagi: what is job id, what is object, xml php array, object, php add file, php simple xml, simple xml php, array xml php, add key, simple figure, xml key file, key xml, php array add, xml error, simplexml, php add product code, simplexml file, simple code key, product xml file, php add, order_id, code php add product, php array xml, php xml array, xml array php

Tentang Majikan:
( 59 ulasan ) Belleville, United States

ID Projek: #4069103

Dianugerahkan kepada:


I can fix this problem of SimpleXML Object. I can complete this work in next few hours.

$15 USD / jam
(673 Ulasan)

5 pekerja bebas membida secara purata $12/jam untuk pekerjaan ini


ready to fix sir

$10 USD / jam
(327 Ulasan)

Hello Sir, I have gone through the details you have provided and would be pleased to work on this with you to deliver the results that you have expected and I am sure you will not be disappointed if you give us Lagi

$8 USD / jam
(42 Ulasan)

Try dumping the var values for $o->price_ex_tax

$15 USD / jam
(20 Ulasan)

Hello, I have 4+ years of experience in website customization and i believe that I can do this. Looking forward to work with you. Thanks

$10 USD / jam
(14 Ulasan)