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]");

2 Answers 2

7
dosomething( array(12,32,56) );
Sign up to request clarification or add additional context in comments.

Comments

1

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));

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.