I would like to learn a smart way to unzip a nested array. For example, I have an array variable $ rma_data ['status'] that looks like this;
[status] => Array
(
[0] => Array
(
[created] => 1233062304107
[statusId] => 5
[statusName] => Open
)
[1] => Array
(
[created] => 1233061910603
[statusId] => 2
[statusName] => New
)
[2] => Array
(
[created] => 1233061910603
[statusId] => 1
[statusName] => Created
)
)
I would like to save the created timestamps and statusId in variables based on conditions such as: if we find that the status is "Open", we will use Open instead of "New" and "Created". If there is only New and Created, we will use New instead.
The current version of my way to do this is:
for($i=0; $i<count($rma_data['status']); $i++)
{
switch($rma_data['status'][$i]['statusId'])
{
case 5:
case 2:
case 3:
}
Any ideas?
source
share