Reorganize the array to merge orders similar to Taobao

Source: Internet
Author: User
{Code...} is similar to the preceding array. You need to combine the same test fields and output them at the front-end. For example, orders of e-commerce websites are merged and online.
Array ('0' => array ('id' => string '22', 'title' => string 'item name ', 'test' => string '000000',) '1' => array ('id' => string '23', 'title' => string 'item name ', 'test' => string '000000',) '2' => array ('id' => string '30', 'title' => string 'item name ', 'test' => string '123 ',))

Similar to the preceding arraytestFields are combined and output at the front-end, similar to orders of e-commerce websites, online, etc.

Reply content:
Array ('0' => array ('id' => string '22', 'title' => string 'item name ', 'test' => string '000000',) '1' => array ('id' => string '23', 'title' => string 'item name ', 'test' => string '000000',) '2' => array ('id' => string '30', 'title' => string 'item name ', 'test' => string '123 ',))

Similar to the preceding arraytestFields are combined and output at the front-end, similar to orders of e-commerce websites, online, etc.

It is actually very simple:

$ Arra = array ('0' => array ('id' => '22', 'title' => 'item name ', 'test' => '123',), '1' => array ('id' => '23', 'title' => 'item name ', 'test' => '123',), '2' => array ('id' => '30', 'title' => 'item name ', 'test' => '123',); $ result = array (); foreach ($ arra as $ key => $ value) {$ result [$ value ['test'] [] = $ value ;}

The result is a three-dimensional array.

Related Article

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.