Jump to content

[SOLVED] Passing array of multidimensional array to function


Primal

Recommended Posts

How do I pass a part of a multidimensional array to a function. I have the following (in pseudo):

 

$arrays[m][n]; // filled with values

$chosen = 3;

 

function doSomething($array) {

// do something with 1D array

}

 

This fails:

 

doSomething($arrays[$chosen]);

 

 

Can someone explain to me why? And how to do this right?

 

You can pass any data type into a function (String, Integer, Array) as long as its functionality in the function reflects its type.  example if I pass the string of Yes I can to a function and then try and multiple it by some value it will value.  The same holds true if you don't handle an array in the function properly

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.