Link to home
Start Free TrialLog in
Avatar of atari2600
atari2600Flag for United Kingdom of Great Britain and Northern Ireland

asked on

Get list from multidimensional array

Hi,

I am trying to get my head around listing values from a PHP multidimensional array. I have been using foreach to try and do it, but can't seem to quite get to the array, inside the array. So for example how would I list all the values for 'Term' in the following example:

Array
(
    [ArrayOfRate] => Array
        (
            [Rate] => Array
                (
                    [0] => Array
                        (
                            [Market] => A*
                            [Term] => 24
                            [MinAdvance] => 1000.00000000
                            [MaxAdvance] => 1099.00000000
                            [APR] => 0.1752
                            [LendingRate] => 0.0593
                            [MonthlyRepayment] => 49.08754600
                            [TotalRepayment] => 1178.10110400
                            [TotalCredit] => 1110.00000000
                            [TotalInterest] => 68.10110400
                            [Fee] => 110.00000000
                        )

                    [1] => Array
                        (
                            [Market] => A*
                            [Term] => 36
                            [MinAdvance] => 1000.00000000
                            [MaxAdvance] => 1099.00000000
                            [APR] => 0.1656
                            [LendingRate] => 0.0593
                            [MonthlyRepayment] => 34.87240500
                            [TotalRepayment] => 1255.40658000
                            [TotalCredit] => 1150.00000000
                            [TotalInterest] => 105.40658000
                            [Fee] => 150.00000000
                        )
		)
	)
)

Open in new window


Thanks.

Paul.
ASKER CERTIFIED SOLUTION
Avatar of Slimshaneey
Slimshaneey
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of atari2600

ASKER

Hi Slimshaneey! Great answer, and I now understand the structure used. It did not work at first, but that was a good thing as I noticed the case was different on the $data['term'] and should have been $data['Term']. That answered another question I had which was "Are arrays case sensitive?", and know I know that they are.

Thank you for your assistance!

Paul
Fast, and exactly what I wanted to learn!
Happy to help! Most of PHP is case sensitive, its an easy mistake to make, I moved from Classic ASP to PHP and got caught out often at first :-)