Multi-dimensional array problems

Source: Internet
Author: User
How can I output the multi-dimensional array to a table in a hierarchical manner?
Array ([0] => Array ([cat_id] => 141 [cat_name] => Latest announcement) [1] => Array ([cat_id] => 117 [cat_name] => [children] => Array ([0] => Array ([cat_id] => 118 [cat_name] => monthly profit and loss) [1] => Array ([cat_id] => 119 [cat_name] => Tourbillon) [2] => Array ([cat_id] => 120 [cat_name] => coaxial capture ))) [2] => Array ([cat_id] => 104 [cat_name] => Bank credit card special offer [children] => Array ([0] => Array ([cat_id] => 105 [cat_name] => China Merchants Bank credit card related services) [1] => Array ([cat_id] => 106 [cat_name] => Minsheng Bank credit card related services) [2] => Array ([cat_id] => 107 [cat_name] => ICBC credit card related services) [3] => Array ([cat_id] => 108 [cat_name] => China Construction Bank credit card related services) [4] => Array ([cat_id] => 109 [cat_name] => Bank of Communications credit card related services) [5] => Array ([cat_id] => 110 [cat_name] => Everbright Bank credit card related services) [6] => Array ([cat_id] => 111 [cat_name] => Agricultural Bank credit card related services) [7] => Array ([cat_id] => 112 [cat_name] => credit card related services of China CITIC Bank) [8] => Array ([cat_id] => 113 [cat_name] => GF bank credit card related services) [9] => Array ([cat_id] => 114 [cat_name] => Shanghai bank credit card related services) [10] => Array ([cat_id] => 115 [cat_name] => Huaxia Bank credit card related services) [11] => Array ([cat_id] => 116 [cat_name] => Pudong Development Bank credit card related services ))) [3] => Array ([cat_id] => 98 [cat_name] => SMS [children] => Array ([0] => Array ([cat_id] => 83 [cat_name] => Mid-Autumn Festival text message [children] => Array ([0] => Array ([cat_id] => 84 [cat_name] => Mid-Autumn Festival text message to lovers) [1] => Array ([cat_id] => 85 [cat_name] => SMS to customers during the Mid-Autumn Festival) [2] => Array ([cat_id] => 86 [cat_name] => SMS to elders during the Mid-Autumn Festival) [3] => Array ([cat_id] => 87 [cat_name] => send text messages to colleagues/leaders during the Mid-Autumn Festival ))) [1] => Array ([cat_id] => 88 [cat_name] => Christmas text message [children] => Array ([0] => Array ([cat_id] => 89 [cat_name] => text message for Christmas lovers) [1] => Array ([cat_id] => 90 [cat_name] => Christmas greeting text message) [2] => Array ([cat_id] => 91 [cat_name] => SMS to elders during Christmas) [3] => Array ([cat_id] => 92 [cat_name] => Christmas funny text message ))))) [4] => Array ([cat_id] => 141 [cat_name] => About Us ))


Reply to discussion (solution)

Please provide the table style

In a common table, tr encapsulates an array. at different levels, tr has a class that is a layer-level value, similar

What is the purpose of posting html code diagrams like this?
Just draw one.

Is it easy? Just give me a thought.

Set your array to $ ar, then

echo '
 
  ';move_bar($ar);echo '
 
';function move_bar($ar, $deep=0) { foreach($ar as $row) { echo "$row[cat_name]\n"; if(isset($row['children'])) { move_bar($row['children'], $deep+1); } }}






























Latest announcement
Consultation on special topics
Monthly Profit and Loss
Tourbillon
Coaxial capture
Bank credit card special offer
China Merchants Bank Credit Card Services
Credit Card Services of Minsheng Bank
ICBC Credit Card Services
China Construction Bank Credit Card Services
Bank of Communications Credit Card Services
Everbright Bank Credit Card Services
Credit card services of the Agricultural Bank
Credit card services of China CITIC Bank
China Guangfa Bank credit card-related services
Shanghai Bank Credit Card Services
Huaxia Bank Credit Card Services
Pudong Development Bank credit card-related services
SMS
Mid-Autumn SMS
SMS for lovers during the Mid-Autumn Festival
SMS to customers during the Mid-Autumn Festival
SMS to elders during the Mid-Autumn Festival
Mid-Autumn Festival text message to colleagues/leaders
Christmas text message
Text messages to lovers during Christmas
Christmas greeting text message
SMS to elders during Christmas
Christmas funny text message
About Us

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.