Loop trough multi dimensional Array correctly for FusionChart |
[eluser]CI_adis[/eluser]
Hi fellow CI-members, I am testing FusionCharts with Code Igniter (as soon I have a good overview I will try to write an Wiki for it, because there are a lot of incomplete tuts about it!). But I am also pretty new to PHP so I have some issues with multi dimensional array's! Consider these two array's: Code: $arrData[0][0] = 'Me'; should be the same as: Code: $arrData = array (12, 13, 14, 6); The first one would be easy to use in FusionCharts: Code: $FC->addChartDataFromArray($arrData); the second one needs a foreach: Code: foreach ( $arrData as $i => $data ) { And my question is: What should i use? (considering performance etc) If you advice the first one, can you provide an example how to add data from a database? Because I have no idea how to built the array while fetching records from a database! Thanks all!
[eluser]Cristian Gilè[/eluser]
Hi CI_adis, Quote:the second one needs a foreach: The second foreach is not necessary: Code: foreach ( $arrData as $i => $data )
[eluser]CI_adis[/eluser]
Hi Cristian Gilè, Thanks, you are right. I do not need the second foreach! Thanks. @all: Still my question is open: How to add values in a multidimensional array while fetching records from a db?
[eluser]Cristian Gilè[/eluser]
Take a look at this screencast: codeigniter from scratch It's a good starting point to learn CI.
[eluser]CI_adis[/eluser]
Thanks for pointing me to this site. I already took lessons 1-6 :-) and achieved pretty nice results with CI. But now I want to integrate FusionCharts and there many topics about FusionCharts with CI but i you follow "their" examples you run into strange issues. Therefore I'm testing it myself to obtain some good knowledge about it. Besides CI I need training for PHP, so i started reading a lot of E-Books :-) Later on I will try to write a complete wiki about CI and FusionCharts. Cheers. |
Welcome Guest, Not a member yet? Register Sign In |