1

Is there a PhP function that can count the number of parameters passed to another function? for example

function tobeCounted ("numberOne","numberTwo","numberThree")
{
 //do something with the parameters
}

a function that will count the number of parameters passed to the function above then return three or the indexes of the parameters or parameters themseleves.

0

5 Answers 5

3

If you use func_num_args() then you get the amount of arguments, rather than func_get_args that gets you the array of arguments.

Sign up to request clarification or add additional context in comments.

Comments

2

func_get_args

Comments

2

You need these:

func_num_args — Returns the number of arguments passed to the function

func_get_args — Returns an array comprising a function's argument list

From here:

http://www.php.net/manual/en/function.func-num-args.php

Comments

1

Or more directly: func_num_args

Comments

1
func_num_args()

Use this to get the number of parameters passed

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.