PHP array output display problems

Source: Internet
Author: User
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 ])?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.