普通网友
2017-09-25 10:20
浏览 48
已采纳

PHP将2维数组转换为字符串

I am trying to convert following array:

array (size=6)
  0 => 
    array (size=1)
      1 => string '611' (length=3)
  1 => 
    array (size=1)
      1 => string '610' (length=3)
  2 => 
    array (size=1)
      1 => string '608' (length=3)
  3 => 
    array (size=1)
      1 => string '607' (length=3)
  4 => 
    array (size=1)
      1 => string '606' (length=3)
  5 => 
    array (size=1)
      1 => string '605' (length=3)

Expected output: 611, 610, 608, 607, 606, 605

I tried to do this:

 foreach ($array as $sub) {
     $str = implode(',', $sub);
 }

but I got 605

Could you explain what I am doing wrong

1条回答 默认 最新

相关推荐 更多相似问题