fork(4) download
  1. <?php
  2.  
  3. function test (array $args) {
  4. $defaults = array('a' => 0, 'b' => 0, 'c' => 0);
  5. $args = array_merge($defaults, array_intersect_key($args, $defaults));
  6.  
  7. list($a, $b, $c) = array_values($args);
  8. echo "a = $a, b = $b, c = $c\n";
  9. }
  10.  
  11. test(array('c' => 3));
  12. test(array('a' => 2, 'b' => 1));
  13.  
Success #stdin #stdout 0.02s 13112KB
stdin
Standard input is empty
stdout
a = 0, b = 0, c = 3
a = 2, b = 1, c = 0