If I do var_dump($this->reports);
I have an array that looks like this:
array(15) {
["Terry CS"]=>
array(1) {
["2011-10-26"]=>
array(2) {
[0]=>
string(5) "69.90"
[1]=>
string(5) "69.90"
}
}
["2011-10-27"]=>
array(3) {
[0]=>
string(6) "199.50"
[1]=>
string(6) "199.50"
[2]=>
string(5) "69.90"
}
}
["Lisa CS"]=>
array(1) {
["2011-10-26"]=>
array(1) {
[0]=>
string(5) "69.90"
}
}
}
how do I read through it so I can data in a table or list?
thanks
Aurelio De Rosa
22.2k8 gold badges51 silver badges71 bronze badges
asked Oct 28, 2011 at 16:18
2 Answers 2
If what you are trying to do is gather the data in order to print it in some tabular form, take a look at the PHP Manual, section foreach.
answered Oct 28, 2011 at 16:21
You can use foreach to iterate on an array:
foreach ($this->reports as $key => &$value) {
var_dump($key, $value);
}
If you want access to a specific data you can do this:
var_dump($this->reports["Terry CS"]);
More information here.
lang-php
print_r()
instead ofvar_dump()
for less confusing overview.