Passing variable number of arguments to a PHP function

Post

2 comments   |   PHP, Useful

function test () {
  $args = func_get_args(); //get all arguments into array
  foreach($args as $num=>$val) {
      echo '<p>'.$val.'</p>'; //print argument
  }
}

The same useful functions:

func_num_args() -get num of passing arguments
func_get_arg(n) - get argument by it number

Leave a Reply

  1. Passing variable number of arguments to a PHP function | sqlphphelp04-02-11
  2. Bitacoras.com04-04-11