Я преобразовал строку XML в массив php. Но требование другое. Ниже приведен массив, созданный с использованием строки XML путем выполнения
$xml = simplexml_load_string($mystin, "SimpleXMLElement", LIBXML_NOCDATA);
$json = json_encode($xml);
$array = json_decode($json,TRUE);
Выход:
Array
(
[0] => Array
(
[data] => Array
(
[0] => Array
(
[attribute_set] => default
[description] => productdescription
[is_in_stock] => 1
[meta_description] => Product meta description
[meta_keyword] => Product meta keyword
[meta_title] => Product meta title
[name] => myproduct6
[price] => 100
[qty] => 1000
[re_skus] => sdfefwef
[short_description] => this is a short descriptio
[sku] => myproduct_surabhi7
[status] => 1
[store] => admin
[tax_class_id] => 4
[type] => simple
[url_key] => my-product
[url_path] => my-product.html
[visibility] => 4
[weight] => 10
)
[1] => Array
(
[attribute_set] => default
[description] => productdescription
[is_in_stock] => 1
[meta_description] => Product meta description
[meta_keyword] => Product meta keyword
[meta_title] => Product meta title
[name] => myproduct6
[price] => 100
[qty] => 1000
[re_skus] => sdfefwef
[short_description] => this is a short descriptio
[sku] => myproduct_surabhi7
[status] => 1
[store] => admin
[tax_class_id] => 4
[type] => simple
[url_key] => my-product
[url_path] => my-product.html
[visibility] => 4
[weight] => 10
)
)
)
)
Мне нужен приведенный выше массив в виде следующего массива:
Array
(
[0] => Array
(
[0] => Array
(
[name] => Product1
[sku] => Product1
[description] => Product description
[short_description] => Product short description
[weight] => 10
[status] => 1
[url_key] => wat12
[url_path] => wat12.html
[visibility] => 4
[price] => 100
[tax_class_id] => 4
[meta_title] => Product meta title
[meta_keyword] => Product meta keyword
[meta_description] => Product meta description
[store] => admin
[attribute_set] => default
[type] => simple
[is_in_stock] => 1
[color] => Orange
[re_skus] => Testsimple2,Testsimple1
)
)
[1] => Array
(
[1] => Array
(
[name] => Product2
[sku] => Product2
[description] => Product description
[short_description] => Product short description
[weight] => 10
[status] => 1
[url_key] => wat12
[url_path] => wat12.html
[visibility] => 4
[price] => 100
[tax_class_id] => 4
[meta_title] => Product meta title
[meta_keyword] => Product meta keyword
[meta_description] => Product meta description
[store] => admin
[attribute_set] => default
[type] => simple
[is_in_stock] => 1
[color] => Orange
[re_skus] => Testsimple2,Testsimple1
)
)
)
Подробнее здесь: https://stackoverflow.com/questions/321 ... cribe-keys
Удаление ненужного уровня из многомерного массива и расшифровка ключей ⇐ Php
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Сортировка первого уровня многомерного массива по первому ключу второго уровня
Anonymous » » в форуме Php - 0 Ответы
- 25 Просмотры
-
Последнее сообщение Anonymous
-
-
-
Сортировка первого уровня многомерного массива по его динамическому ключу второго уровня.
Anonymous » » в форуме Php - 0 Ответы
- 47 Просмотры
-
Последнее сообщение Anonymous
-