PHP Array output display problem 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 )))
This is the data that is divided into two groups. The key value [0] and [1] have three data records respectively.
Now you want to display them separately
First Group: (key value 0) 2IT14035A, 5IE14032S, 1IE15003B, 1IE15010C
Second Group: (key value 1) 1IE14210D, 1IE15001A, 1IT15001G, 1IT14033S
What should I do?
Thank you!
Reply to discussion (solution)
$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 ))
Still
$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)
Second. Thank you very much.
If I want to display it on a webpage
Group 1: 2IT14035A, 5IE14032S, 1IE15003B, 1IE15010C
Group 2: 1IE14210D, 1IE15001A, 1IT15001G, 1IT14033S
Directly print_r ($ r [0 ])?