如何将多树数组内爆为字符串

How to implode multi tree array to string

我正在尝试将这种类型的数组分解为字符串。我该怎么做?

Array ( 
  [58] => Array ( 
    [272] => Array ( ) 
    [273] => Array ( ) 
    [274] => Array ( ) 
    [275] => Array ( ) 
    [276] => Array ( ) 
    [507] => Array ( ) 
  )
  [182] => Array ( 
    [46] => Array ( ) 
    [96] => Array ( ) 
  ) 
  [271] => Array ( 
    [2] => Array ( ) 
    [75] => Array ( ) 
    [80] => Array ( ) 
  ) 
  [277] => Array ( ) 
  [278] => Array ( 
    [4] => Array ( [174] => Array ( ) ) 
    [14] => Array ( ) 
    [36] => Array ( ) 
    [57] => Array ( ) 
    [279] => Array ( ) 
    [280] => Array ( ) 
    [281] => Array ( ) 
  ) 
)

我想得到这样的结果:58、272、273、274、275、276、507、182 ...

你试过 implode() 吗? See this

我必须说你的数组很奇怪,但这是我从你的代码和请求中得到的:

$thing = Array ( 
        58 => Array ( 272 => Array ( ), 273 => Array ( ), 274 => Array ( ), 275 => Array ( ), 276 => Array ( ), 507 => Array ( ) ),
        182 => Array ( 46 => Array ( ), 96 => Array ( ) ),
        271 => Array ( 2 => Array ( ), 75 => Array ( ), 80 => Array ( ) ),
        277 => Array ( ),
        278 => Array ( 4 => Array ( 174 => Array ( ) ), 14 => Array ( ), 36 => Array ( ), 57 => Array ( ), 279 => Array ( ), 280 => Array ( ), 281 => Array ( ) ) 
      );
$temp=[];
function husk_that_thing($array,&$temp)
{
  foreach ($array as $key => $value) 
  {
    $temp[]=$key;
    if($value)
    {
      husk_that_thing($value,$temp);
    }
  }
}
husk_that_thing($thing,$temp);
echo implode(',',$temp);//output