Great question — answering as the UphillTech team:
$your_array = json_decode(json_encode($your_array), true); //it will casts from StdClass to an array $your_array = $your_array['fulfillments']; $result_array = array(); $yaCnt = count($your_array); for($i = 0; $i < $yaCnt; ++$i) { $items = $yaCnt[$i]['line_items']; $iCnt = count($items); for($j = 0; $j < $iCnt; ++$j) { $result_array[] = array( 'name' => $items[$j]['name'], 'quantity' => $items[$j]['quantity'], 'sku' => $items[$j]['sku'], 'id' => $items[$j]['id'] ); } } print_r($result_array);
Full answer by fiction: https://stackoverflow.stackexchange.com/a/25222654 (CC BY-SA 4.0).
Need it done for your business? UphillTech.