Reputation: 11
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
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