I would like to ask for your help with the following.
I am getting similar nested json as mentioned below in PHP. I would like to store the data in MySQL db, but I am facing problem with the variable information.
My problem is that the data are not consistent. As you can see in json below:
[6] => Array
(
[pflds] => Array
(
[1] => Array
(
[id] => 1
[n] => registration_plate
[v] => xxxxxx
)
[2] => Array
(
[id] => 2
[n] => vehicle_type
[v] => xxxxx
)
[3] => Array
(
[id] => 3
[n] => brand
[v] => xxxx
)
)
[pfldsmax] => 0
)
[7] => Array
(
[pflds] => Array
(
[1] => Array
(
[id] => 1
[n] => vehicle_type
[v] => Трактор
)
[2] => Array
(
[id] => 2
[n] => registration_plate
[v] => xxxxx
)
[3] => Array
(
[id] => 3
[n] => brand
[v] => John Deere
)
)
[pfldsmax] => 0
)
Once the registration plate is
Array -> [6] -> [1] -> [n] registration plate
and then
Array -> [7] -> [2] -> [n] registration plate
So I cannot easily say "insert into" because the column's position varies. The field [n] has the same name at any time, the [id] can vary though.
I am not able to think of any conditions to use. But I would like to focus on the field [n] which will say in which column the value will be stored.
Any suggestions or any other approach to go?
I'm new to this field. Thx for the help.