How to generate an array

Source: Internet
Author: User
How to generate an array has two fields $ cont_type and $ cont_id in a table in the mysql database, and each of them has more than one record, how do I generate such a 2-dimensional array? $ tarTree [$ cont_type] [] = $ cont_id; do I use mysql_fetch_row ()?


Reply to discussion (solution)

// After reading the code, generate a two-dimensional array and paste the sample code directly.

 

Implementation
1. read data in one row and one row
2. each time a row of data is read, $ row ['cont _ type'] is passed to $ tarTree as a key, $ row ['cont _ id'] is passed as the key value to the two-dimensional array.

A classic example is also applicable to YII.

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.