Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Php accessing key values in multi dimensional arrays

Options
  • 30-06-2013 7:06pm
    #1
    Registered Users Posts: 7,639 ✭✭✭


    I am using cakephp as my framework and it is sending an array called people that is multi-dimensional to my view.


    i have attached a screenshot of what the array looks like basically.

    I am currently iterating over that array and displayying the values in a table. I want the first row in the table to be the table column name headings but instead of me just entering them I want them to update dynamically if I add or remove a field from the table

    I have been trying things like this and I can get it to echo the numeric id for the $people array as a hole and I can get it to echo 'people' when it goes one step further into the array but I cant get it to go in one more level deeper and echo the keys

    [PHP]if (isset($people[0][0])) {
    foreach ($people[0] as $key => $value) {
    echo $key;
    }[/PHP]

    any ideas?


Advertisement