raj
raj

Reputation: 11

How to pass multidimensional array into a function

I don't know how to pass a multidimensional array to a function and how to specify the data type in the function definition.

Upvotes: 1

Views: 5003

Answers (1)

elviejo79
elviejo79

Reputation: 4600

Do you mean something like?

<?php
$arr = array('home'=>array(
                           'living room',
                            'bedroom'
                           ),
              'office'=>array(
                              'conference room',
                              'cubicule',
                             )
             );
function myFunction ( $myArray) {
  echo "<pre>look nested arrays are passed into functions just like regular arrays, it just works\n".
        print_r($myArray,true).
        '</pre>';
}
myFunction ($arr);

It just works.

Upvotes: 3

Related Questions