Jump to content

array within array to function


benjaminbeazy

Recommended Posts

i've got an idea for a class that templates a search page with filters and results that can be called with just a couple arrays and queries but is it possible to put an array within an array and is it possible to pass such an array to a function???

Link to comment
https://forums.phpfreaks.com/topic/38893-array-within-array-to-function/
Share on other sites

yes, PHP supports multi-dimensional array.

 

$multiArray = array ('fruit'=> array('apple', 'banana'),
                            'veggie'=> array('lectuce', 'salad'));

 

now

$multiArray['fruit'] is an array contain 'apple' and 'banana'.

$multiArray['veggie'] is an array contains 'lectuce' and 'salad'

 

You can also pass this $multiArray as an argument of a function like:

 

myfunc($multiArray);

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.