i have this Json
output and i want to get specific values from it, this is the json
:
[
[
[
"a:1:{s:3:\"ALL\";d:100;}",
"a:1:{s:3:\"ALL\";d:200;}",
"a:1:{s:3:\"ALL\";d:89;}"
],
[
"a:1:{s:3:\"USD\";d:100;}"
],
[
"a:2:{s:3:\"ALL\";d:300;s:3:\"USD\";d:250;}"
],
[
"a:1:{s:3:\"ALL\";d:30;}",
"a:2:{s:3:\"ALL\";d:100;s:3:\"USD\";d:200;}"
],
[
"a:1:{s:3:\"USD\";d:200;}"
]
]
]
So i want to get the first d
value only which are the numbers, for the moment i tried something like this:
$values = explode('-',$this->currency);
return $values[0];
But its not working, i know i have to use a foreach
to get the rest but dont know how to get the value for one.
EDIT I did this code:
$values = explode('-',$this->currency);
foreach ($values as $val){
$arr[] = unserialize($val);
}
return $arr;
And this is what i get
[
[
[
{
"ALL": 100
},
{
"ALL": 200
},
{
"ALL": 89
}
],
[
{
"USD": 100
}
],
[
{
"ALL": 300,
"USD": 250
}
],
[
{
"ALL": 30
},
{
"ALL": 100,
"USD": 200
}
],
[
{
"USD": 200
}
]
]
]
So right now the output is correct but i need to get specific values for example on the first array we have 3 ALL
values 100, 200, 89 i want to make a loop that gives me separatly 100, 200, 89 so i can find their total sum. The rest for the other numbers
SECOND EDIT
If i just make
$values = explode('-',$this->currency);
return $values;
i get this result:
[
[
[
"a:1:{s:3:\"ALL\";d:100;}",
"a:1:{s:3:\"ALL\";d:200;}",
"a:1:{s:3:\"ALL\";d:89;}"
],
[
"a:1:{s:3:\"USD\";d:100;}"
],
[
"a:2:{s:3:\"ALL\";d:300;s:3:\"USD\";d:250;}"
],
[
"a:1:{s:3:\"ALL\";d:30;}",
"a:2:{s:3:\"ALL\";d:100;s:3:\"USD\";d:200;}"
],
[
"a:1:{s:3:\"USD\";d:200;}"
]
]
]