views:

39

answers:

2

Here is the code :

function dosomething ()
{
  ... do something with the array... like print value !
}

$ar = array(1,2,3);
dosomething ($ar);

That piece of code work fine...

What i try to do is to pass the array DIRECTLY to the function i have try this, non work... HELP !

dosomething ([12,32,56]);
dosomething ({12,45,87});
dosomething ("[98,74,52]");
+5  A: 
dosomething( array(12,32,56) );
Amber
+1  A: 

first you have to specify the parameter in the function:

function dosomething($array) { var_dump($array); }

Then you have to pass the array and define it like you did in your code but directly in the function:

dosomething(array(1,2,3));
u2ix