Returns an associative array comprising a function's argument list in php

Posted by diEcho on Stack Overflow See other posts from Stack Overflow or by diEcho
Published on 2011-01-15T08:40:14Z Indexed on 2011/01/15 8:53 UTC
Read the original article Hit count: 290

Hello All,

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

it returns numeric index array

is there any function/way in php by which we get associative array i.e. key=>value pair

i m explaining with example:

test.php

<?php

function foo() {
    include './fga.inc';
}
$x=20;
$y=30;

foo($x, $y);
?>

fga.inc

<?php

$args = func_get_args();
echo "<pre>";
print_r($args);
echo "</pre>";

?>

which should returns

array (
  'x'=> 20,
  'y' => 30,
)

© Stack Overflow or respective owner

Related posts about php

Related posts about associative-array