如何在数组中获取复杂值?

This is my JSON array

Array
(
    [0] => Array
        (
            [active] => Y
                (
                    [0] => Array
                        (
                            [sub] => 5
                        )
                )
        )
)

My question how can I get value 5 in sub by using foreach.

Use this

foreach($results['data'] as $result) {
      if(is_array($result)) {
           print_r($result) ;
           echo '<br>';
      } else {
           echo $result['type'] . '<br>';
      }   
}

Try this:

foreach ($rs_amount as $result) {
    foreach ($result['sub_resource'] as $sub_resource) {
        foreach ($sub_resource as $subs) {
            echo $subs['sub'] . "<br/>";
        }
    }
}