TechniqueUse the func_get_args() function to return an array containing the arguments passed to the function: <?php $input_record_seperator = " "; function perl_print () { $args = func_get_args(); foreach ($args as $arg) { print $arg . $input_record_seperator; } } perl_print("Hello World\n", "My Name is", "Sterling"); ?> CommentsPHP offers a set of handy functions for accepting an arbitrary amount of parameters. The func_get_args() function returns an array of all the function arguments passed to the script. As an alternative, you can also use the func_get_arg() and func_num_args() functions to loop through all the parameters sent to a function: <?php $input_record_separator = " "; function perl_print () { $argc = func_num_args(); for ($idx = 0; $idx < $argc; $idx++) { $current_arg = func_get_arg($idx); print $current_arg . $input_record_separator; } } ?> |