I have the following json string which is stored in my database:
{"Monomeer5e68d7e547620":{"naam":"Monomeer","url":"https:\/\/website.nl\/new\/folie\/monomeer","afbeelding":"assets\/images\/noimg.jpg","aantal":"5","prijs":"2.28","totaalprijs":"20.4","hoogte":"20","breedte":"20","uploaden":"1","specificaties":"Array","controle":"1"},"Elastieken5e68d7e5477b6":{"naam":"Elastieken","url":"https:\/\/website.nl\/new\/folie\/monomeer","afbeelding":"assets\/images\/noimg.jpg","aantal":"1","prijs":"4.50","totaalprijs":"4.5","hoogte":"","breedte":"","uploaden":"0","specificaties":"","controle":""},"Tiewraps5e68d7e5477c8":{"naam":"Tiewraps","url":"https:\/\/website.nl\/new\/folie\/monomeer","afbeelding":"assets\/images\/noimg.jpg","aantal":"1","prijs":"9.95","totaalprijs":"9.95","hoogte":"","breedte":"","uploaden":"0","specificaties":"","controle":""}}
It contains product information that is otherwise shown by a session which looks like this:
Array
(
[Monomeer5eeb62474c5ba] => Array
(
[naam] => Monomeer
[url] => https://website.nl/new/folie/monomeer
[afbeelding] => assets/images/noimg.jpg
[aantal] => 1
[hoogte] => 5
[breedte] => 11
[uploaden] => 1
[specificaties] => Array
(
[Lijmlaag] => Array
(
[waarde] => Wit
)
[Laminaat] => Array
(
[waarde] => Mat laminaat
)
[Afwerking] => Array
(
[waarde] => Contoursnijden
)
)
[prijs] => 0.3355
[totaalprijs] => 0.3355
)
[Elastieken5eeb62474c74f] => Array
(
[naam] => Elastieken
[url] => https://website.nl/new/folie/monomeer
[afbeelding] => assets/images/noimg.jpg
[aantal] => 1
[prijs] => 4.50
[totaalprijs] => 4.5
[uploaden] => 0
)
[Tiewraps5eeb62474c760] => Array
(
[naam] => Tiewraps
[url] => https://website.nl/new/folie/monomeer
[afbeelding] => assets/images/noimg.jpg
[aantal] => 1
[prijs] => 9.95
[totaalprijs] => 9.95
[uploaden] => 0
)
)
When the session is expired, I want someone to be able to look up their order information again, so on the page that displays this I am trying to build a check (see if session exists, if yes loop over the session, if not loop over the php array that is exactly the same as the session). But to get the same array as my session it needs to be converted from a JSON string.
How can I do that? Convert the above JSON string to a PHP array that looks the same as my PHP session contents.
When I try decoding the json string, this is what I get:
stdClass Object (
[Monomeer5ee48a5bddfd1] => stdClass Object (
[naam] => Monomeer
[url] => https://website.nl/new/folie/monomeer [afbeelding] => assets/images/noimg.jpg
[aantal] => 4
[prijs] => 1.785
[totaalprijs] => 7.14
[hoogte] => 5
[breedte] => 10
[uploaden] => 1
[specificaties] => Array [controle] =>
)
[Elastieken5ee48a5bde03a] => stdClass Object (
[naam] => Elastieken
[url] => https://website.nl/new/folie/monomeer
[afbeelding] => assets/images/noimg.jpg
[aantal] => 1
[prijs] => 4.50
[totaalprijs] => 4.5
[hoogte] =>
[breedte] =>
[uploaden] => 0
[specificaties] => [controle] =>
)
[Tiewraps5ee48a5bde048] => stdClass Object (
[naam] => Tiewraps
[url] => https://website.nl/new/folie/monomeer
[afbeelding] => assets/images/noimg.jpg
[aantal] => 1
[prijs] => 9.95
[totaalprijs] => 9.95
[hoogte] =>
[breedte] =>
[uploaden] => 0
[specificaties] => [controle] =>
)
)