1

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

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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.