-Karl- Posted July 4, 2010 Share Posted July 4, 2010 Okay, I have an array. Doing print_r($array); shows: Array ( [1.2GHZ CPU 384 Mb Guranteed RAM 512 Mb Burstable RAM 25 Gb Hard Drive 10 Mbit Connection Unmetered Premium Bandwidth No setup fees Instant activation Dedicated ip address Full root access Directadmin Control panel Free reboot and repair console Easy to use interface Free live support Choice of linux distribution ] => Array ( [0] => ) [1.8GHZ CPU 512 Mb Guranteed RAM 640 Mb Burstable RAM 45 Gb Hard Drive 10 Mbit Connection Upgradeable to 20Mbit Unmetered Premium Bandwidth No setup fees Instant activation Dedicated ip address Full root access Directadmin Control panel Free reboot and repair console Easy to use interface Free live support Choice of linux distribution ] => Array ( [1] => ) [2.4GHZ CPU 640 Mb Guranteed RAM 786 Mb Burstable RAM 75 Gb Hard Drive 10 Mbit Connection Upgradeable to 50Mbit Unmetered Premium Bandwidth No setup fees Instant activation Dedicated ip address Full root access Directadmin Control panel Free reboot and repair console Easy to use interface Free live support Choice of linux distribution ] => Array ( [2] => ) [3.0GHZ CPU 768 Mb Guranteed RAM 1024 Mb Burstable RAM 125 Gb Hard Drive 20 Mbit Connection Upgradeable to 100Mbit Unmetered Premium Bandwidth No setup fees Instant activation Dedicated ip address Full root access Directadmin Control panel Free reboot and repair console Easy to use interface Free live support Choice of linux distribution ] => Array ( [3] => ) [4.0GHZ CPU 1024 Mb Guranteed RAM 1536 Mb Burstable RAM 200 Gb Hard Drive 50 Mbit Connection Upgradeable to 100Mbit Unmetered Premium Bandwidth No setup fees Instant activation Dedicated ip address Full root access Directadmin Control panel Free reboot and repair console Easy to use interface Free live support Choice of linux distribution ] => Array ( [4] => ) [2x4.0GHZ Dual Core CPU 1536 Mb Guranteed RAM 2048 Mb Burstable RAM 300 Gb Hard Drive 100 Mbit Connection Unmetered Premium Bandwidth No setup fees Instant activation Dedicated ip address Full root access Directadmin Control panel Free reboot and repair console Easy to use interface Free live support Choice of linux distribution ] => Array ( [5] => ) ) What I'm trying to do is create a table: Features plan 1 plan 2 Feature 1 1.2GHZ CPU 1.8GHZ CPU Feature 2 x RAM x RAM And so on. I've been racking my brains out for hours trying to do this. After starting from scratch again, all I have is: $titles = array('CPU Share','Guaranteed RAM','Burstable RAM','HDD Space','Bandwidth'); $t = 0; print_r($Features); foreach ($titles as $value) { echo '<tr><td>'.$value.'</td><td>'.$Val[0][0].'</td><td>Package 2</td><td>Package 3</td><td>Package 4</td><td>Package 5</td><td>Package 6</td></tr>'; } Quote Link to comment https://forums.phpfreaks.com/topic/206719-creating-a-table-from-array/ Share on other sites More sharing options...
travo1992 Posted July 4, 2010 Share Posted July 4, 2010 Looking at the print_r output, I think your array may not be right. Can you please post the code where you created it? Quote Link to comment https://forums.phpfreaks.com/topic/206719-creating-a-table-from-array/#findComment-1081112 Share on other sites More sharing options...
GetFreaky Posted July 5, 2010 Share Posted July 5, 2010 Theres is only 1 key in your array, you cant break it down... its supose to be array("Ram" => "384 Mb", "Harddrive"=>"25 Gb"); or array("384 Mb Guranteed RAM","512 Mb Burstable RAM","25 Gb Hard Drive","Choice of linux distribution"); If you need more information regarding Arrays and Multidimensional Array then goto PHP.net/array or http://www.webcheatsheet.com/PHP/multidimensional_arrays.php Quote Link to comment https://forums.phpfreaks.com/topic/206719-creating-a-table-from-array/#findComment-1081114 Share on other sites More sharing options...
PFMaBiSmAd Posted July 5, 2010 Share Posted July 5, 2010 If you use <pre> </pre> tags around your print_r() statement, it will make it much easier for you and others to see what your data actually is - echo "<pre>",print_r($Features,true),"</pre>"; Quote Link to comment https://forums.phpfreaks.com/topic/206719-creating-a-table-from-array/#findComment-1081128 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.