Rumah >pembangunan bahagian belakang >tutorial php >PHP 数组输出显示的问题

PHP 数组输出显示的问题

WBOY
WBOYasal
2016-06-23 13:18:001000semak imbas

Array ( [0] => Array ( [0] => Array ( [ID] => 2IT14035A ) [1] => Array ( [ID] => 5IE14032S ) [2] => Array ( [ID] => 1IE15003B ) [3] => Array ( [ID] => 1IE15010C ) ) [1] => Array ( [0] => Array ( [ID] => 1IE14210D ) [1] => Array ( [ID] => 1IE15001A ) [2] => Array ( [ID] => 1IT15001G ) [3] => Array ( [ID] => 1IT14033S ) ) ) 
这是被分为两个组的数据,键值【0】和【1】里面分别又有3个数据
现在想分开显示
第一组:(键值为0的)2IT14035A, 5IE14032S,1IE15003B,1IE15010C
第二组:(键值为1的)1IE14210D,1IE15001A, 1IT15001G,1IT14033S
该怎么办呢 
谢谢大家


回复讨论(解决方案)

$a = array (  0 =>   array (    0 =>     array (      'ID' => '2IT14035A',    ),    1 =>     array (      'ID' => '5IE14032S',    ),    2 =>     array (      'ID' => '1IE15003B',    ),    3 =>     array (      'ID' => '1IE15010C',    ),  ),  1 =>   array (    0 =>     array (      'ID' => '1IE14210D',    ),    1 =>     array (      'ID' => '1IE15001A',    ),    2 =>     array (      'ID' => '1IT15001G',    ),    3 =>     array (      'ID' => '1IT14033S',    ),  ),);foreach($a as $k=>$v) $r[$k] = array_map('current', $v);print_r($r);
Array(    [0] => Array        (            [0] => 2IT14035A            [1] => 5IE14032S            [2] => 1IE15003B            [3] => 1IE15010C        )    [1] => Array        (            [0] => 1IE14210D            [1] => 1IE15001A            [2] => 1IT15001G            [3] => 1IT14033S        ))

还是要这样

$a = array (  0 =>   array (    0 =>     array (      'ID' => '2IT14035A',    ),    1 =>     array (      'ID' => '5IE14032S',    ),    2 =>     array (      'ID' => '1IE15003B',    ),    3 =>     array (      'ID' => '1IE15010C',    ),  ),  1 =>   array (    0 =>     array (      'ID' => '1IE14210D',    ),    1 =>     array (      'ID' => '1IE15001A',    ),    2 =>     array (      'ID' => '1IT15001G',    ),    3 =>     array (      'ID' => '1IT14033S',    ),  ),);foreach($a as $k=>$v) $r[$k] = join(',', array_map('current', $v));print_r($r);
Array(    [0] => 2IT14035A,5IE14032S,1IE15003B,1IE15010C    [1] => 1IE14210D,1IE15001A,1IT15001G,1IT14033S)

第二种。太感谢您了。
如果我想显示到网页上
第一组:2IT14035A,5IE14032S,1IE15003B,1IE15010C
第二组:1IE14210D,1IE15001A,1IT15001G,1IT14033S
直接print_r($r[0]) 对吗

Kenyataan:
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn