Answer the question
In order to leave comments, you need to log in
How to split received data by php script into appropriate arrays for insert in mysql?
Specify the path, please.
There is json data received via API and I don’t know how to bring it into the form that is needed for insert in mysql. I can not understand. Here, as I understand it, there are arrays and multidimensional arrays, can you give an example of a script for this JSON?
{"data":[
{
"sku":"100008",
"name":"Тетрадь ЗЕЛЁНАЯ обложка 12 листов \"Архбум\", офсет, клетка с полями, AZ02",
"category_list":["26551","216228","216560"],
"manufacturer":"Россия","vendor_code":"AZ02",
"barcode":"4607106500012","brand":"АРХБУМ",
"description":"Школьная тетрадь с классической зеленой обложкой формата А5.","description_ext":"",
"weight":"0.035",
"volume":"0.0001",
"characteristic_list":[
"Линовка блока: клетка","Количество листов: 12","Обложка: \"зеленая\"","Формат: А5","Наличие полей: да","Тип скрепления: скрепка","Внутренний блок: офсет","Плотность внутреннего блока: 60 г\/м2","Однотонный дизайн обложки: да","Количество дизайнов в упаковке: 1","Длина: 205 мм","Ширина: 165 мм"],
"facet_list":[
{"name":"Количество листов","value":"12"},
{"name":"Линовка блока","value":"клетка"},
{"name":"Обложка","value":"\"зеленая\""},
{"name":"Формат","value":"А5"},
{"name":"Наличие полей","value":"да"},
{"name":"Плотность внутреннего блока","value":"60"},
{"name":"Однотонный дизайн обложки","value":"да"},
{"name":"Количество дизайнов в упаковке","value":"1"},
{"name":"Тип скрепления","value":"скрепка"},
{"name":"Внутренний блок","value":"офсет"},
{"name":"Длина","value":"205"},
{"name":"Ширина","value":"165"}],
"photo_list":[
"https:\/\/api.samsonopt.ru\/goods\/100008\/be38ddab59d7fba9a59a630296003d3b_x.jpg","https:\/\/api.samsonopt.ru\/goods\/100008\/efa62448d9fa58c0eb3896957a255d7b_x.jpg","https:\/\/api.samsonopt.ru\/goods\/100008\/913e14bf7b61e38fc7f579f59b034b1e_x.jpg","https:\/\/api.samsonopt.ru\/goods\/100008\/f2a092282eb1a2c79de876e4c86c1cd7_x.jpg","https:\/\/api.samsonopt.ru\/goods\/100008\/7b9708521771c130b0b0db8024d06b81_x.jpg"],
"package_list":[
{"type":"min_opt","value":"420"},
{"type":"min_kor","value":"20"},
{"type":"pzk","value":"420"},
{"type":"intermediate","value":"420"},
{"type":"transport","value":"420"}],
"price_list":[
{"type":"contract","value":"3.09"},
{"type":"infiltration","value":"6.53"}],
"stock_list":[{"type":"idp","value":"2010"},
{"type":"transit","value":"0"},
{"type":"distribution_warehouse","value":"135089"}],
"attribute_list":[
{"type":"novelty","value":"false"}],
"sale_date":""
},
{
"sku":"100009",
"name":"Тетрадь ЗЕЛЁНАЯ обложка 12 листов \"Архбум\", офсет, линия с полями, AZ01",
"category_list":["26551","216228","216560"],
"manufacturer":"Россия",
"vendor_code":"AZ01",
"barcode":"4607106500029",
"brand":"АРХБУМ",
"description":"Школьная тетрадь с классической зеленой обложкой формата А5.",
"description_ext":"","weight":"0.035","volume":"0.0001",
"characteristic_list":["Линовка блока: линия","Количество листов: 12","Обложка: \"зеленая\"","Формат: А5",
"Наличие полей: да","Тип скрепления: скрепка","Внутренний блок: офсет","Плотность внутреннего блока: 60 г\/м2",
"Однотонный дизайн обложки: да","Количество дизайнов в упаковке: 1","Длина: 205 мм","Ширина: 165 мм"],
"facet_list":[
{"name":"Количество листов","value":"12"},
{"name":"Линовка блока","value":"линия"},
{"name":"Обложка","value":"\"зеленая\""},
{"name":"Формат","value":"А5"},
{"name":"Наличие полей","value":"да"},
{"name":"Плотность внутреннего блока","value":"60"},
{"name":"Однотонный дизайн обложки","value":"да"},
{"name":"Количество дизайнов в упаковке","value":"1"},
{"name":"Тип скрепления","value":"скрепка"},
{"name":"Внутренний блок","value":"офсет"},
{"name":"Длина","value":"205"},
{"name":"Ширина","value":"165"}],
"photo_list":["https:\/\/api.samsonopt.ru\/goods\/100009\/be38ddab59d7fba9a59a630296003d3b_x.jpg","https:\/\/api.samsonopt.ru\/goods\/100009\/7ea6ca2930c6d32416f2ed19df6ad805_x.jpg","https:\/\/api.samsonopt.ru\/goods\/100009\/fed7f26d6d20beb58959cb49cdefc27d_x.jpg","https:\/\/api.samsonopt.ru\/goods\/100009\/f2a092282eb1a2c79de876e4c86c1cd7_x.jpg","https:\/\/api.samsonopt.ru\/goods\/100009\/7b9708521771c130b0b0db8024d06b81_x.jpg"],
"package_list":[
{"type":"min_opt","value":"420"},
{"type":"min_kor","value":"20"},
{"type":"pzk","value":"420"},
{"type":"intermediate","value":"420"},
{"type":"transport","value":"420"}],
"price_list":[
{"type":"contract","value":"3.09"},
{"type":"infiltration","value":"6.53"}],
"stock_list":[
{"type":"idp","value":"1260"},
{"type":"transit","value":"0"},
{"type":"distribution_warehouse","value":"7775"}],
"attribute_list":[{"type":"novelty","value":"false"}],
"sale_date":""
}
]
}
Answer the question
In order to leave comments, you need to log in
After code:
get an array of data in $json_data:
Array
(
[data] => Array
(
[0] => Array
(
[sku] => 100008
[name] => Тетрадь ЗЕЛЁНАЯ обложка 12 листов "Архбум", офсет, клетка с полями, AZ02
[category_list] => Array
(
[0] => 26551
[1] => 216228
[2] => 216560
)
[manufacturer] => Россия
[vendor_code] => AZ02
[barcode] => 4607106500012
[brand] => АРХБУМ
[description] => Школьная тетрадь с классической зеленой обложкой формата А5.
[description_ext] =>
[weight] => 0.035
[volume] => 0.0001
[characteristic_list] => Array
(
[0] => Линовка блока: клетка
[1] => Количество листов: 12
[2] => Обложка: "зеленая"
[3] => Формат: А5
[4] => Наличие полей: да
[5] => Тип скрепления: скрепка
[6] => Внутренний блок: офсет
[7] => Плотность внутреннего блока: 60 г/м2
[8] => Однотонный дизайн обложки: да
[9] => Количество дизайнов в упаковке: 1
[10] => Длина: 205 мм
[11] => Ширина: 165 мм
)
[facet_list] => Array
(
[0] => Array
(
[name] => Количество листов
[value] => 12
)
...........
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question