PHP get the name of arrays in multidimensional array

I have a simple multidimensional array with two other arrays in it.

            $data = array(
              'first_array' => array(
                'name' => 'Test1',
                'description' => '...',
              'second_array' => array(
                'title' => 'Test2',
                'description' => '...',

And I have a simple foreach array like this:

 function show($data, $id){

                 foreach ($data as $course) {



How can I display (and get) the name of the array in every iteration (I mean if it is 'first_array' or 'second_array', not the name fields in the arrays).


Use key=>val syntax

foreach ($data as $key=>$course) {
    echo $key;

use this syntax for foreach :

foreach ($data as $name => $course) {
    //do sth

Need Your Help

How can I properly chain custom methods in Ruby?

ruby-on-rails ruby methods method-chaining

I am trying to do a chaining method for the following two methods. After running this code, I kept getting the following output: