I need some help on how to update a multidimensional array in PHP. I am using the following array to update a grid of images. The number of my images varies.First I upload and resize my images and then save them in the images field as Json in database.I set the image size to 300 by default and save it in thumb field. This my json images field that i store it in database:
[
{
"images": {
"300": "/storage/uploads/300.1.png",
"600": "/storage/uploads/600.1.png",
"900": "/storage/uploads/900.1.png",
"original": "/storage/uploads/1.png"
},
"thumb": "/storage/uploads/300.1.png"
},
{
"images": {
"300": "/storage/uploads/300.2.png",
"600": "/storage/uploads/600.2.png",
"900": "/storage/uploads/900.2.png",
"original": "/storage/uploads/2.png"
},
"thumb": "/storage/uploads/300.2.png"
},
{},
{}
]
For example, suppose I want to edit the size of the second image and change it from 300 to 600.This is the request log I get from the edit form.
array:3 [▼
"_token" => "wZSerggegrgL1lcbhWZFwerfwerfwerfVx"
"_method" => "patch"
"imagesThumb" => array:4 [▼
"/storage/uploads/300.1.png" => "/storage/uploads/300.1.png"
"/storage/uploads/300.2.png" => "/storage/uploads/600.2.png"
"/storage/uploads/300.3.png" => "/storage/uploads/300.3.png"
"/storage/uploads/300.4.png" => "/storage/uploads/300.4.png"
]
]
How do I update the thumb of the second image?