3v4l.org

run code in 300+ PHP versions simultaneously
<?php $testArray= array( 'test1' => 'SingleValue1', 'test2' => 'SingleValue2' ); function deepestArrays($array,$level=0,&$lowest=[]){ if(sizeof($subarrays=array_filter($array,function($v){return is_array($v);}))){ // isolate subarrays, iterate if any foreach($subarrays as $subs){ deepestArrays($subs,$level+1,$lowest); // recurse each subarray } }else{ if(!sizeof($lowest) || ($lowest_level=key($lowest))==$level){ // if $levels is empty or current $level equals $lowest_level $lowest[$level][]=$array; // append the array to the results }elseif($lowest_level<$level){ $lowest=[$level=>[$array]]; // clear previous storage, store new lowest array } } return current($lowest); // use current() to strip the temporary level identifying key } var_export(deepestArrays($testArray));
Output for 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.34, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.19, 8.3.0 - 8.3.7
array ( 0 => array ( 'test1' => 'SingleValue1', 'test2' => 'SingleValue2', ), )

preferences:
303.17 ms | 404 KiB | 300 Q