i'm trying to build a json array in php, but a more complex one. The point is, that i'm trying to make a database for dish calculations, and the array should look something like that.
Each dish has a name, a base weight, diameter and height. It also has half-finished products that include a single product with its weight.
For example There's a finished product Called "Cake" they base weight is 750 g., the height is 8cm and the diameter is 8cm. Now this cake is made from 3 different half-products that build up the 750g.:
- Dough (300 g.)
- Icing (300 g.)
- Decorations. (150 g.)
And now every half-product has its own single product that builds it up
Dough: 300g.
- Flour 100g
- Water 100 g
- Something else 100g.
And so on for every half product.
I've tried building arrays but this one seems a bit to hard for me, any suggestions on how todo this? Thanks!
EDIT: I need to get something like this
[
{
"Title": "Cake",
"base_weight": 750,
"base_height": 8,
"base_diameter": 14,
"half_products": [
{
"title": "Dough",
"weight": 300,
"ingredients": [
{
"title": "Flour",
"Weight": 150
},
{
"title": "Water",
"Weight": 150
}
]
},
{
"title": "Icing",
"weight": 300,
"ingredients": [
{
"title": "Flour",
"Weight": 150
},
{
"title": "Water",
"Weight": 150
}
]
},
{
"title": "Decorations",
"weight": 150,
"ingredients": [
{
"title": "Flowers",
"Weight": 150
}
]
}
]
}
]