1

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
  • Why do you call it an OO array? Commented Oct 28, 2011 at 16:20
  • 1
    Just a normal array. Use print_r() instead of var_dump() for less confusing overview. Commented Oct 28, 2011 at 16:21

2 Answers 2

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
0

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.

answered Oct 28, 2011 at 16:33

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.