I'm trying to pass an array that has defined keys into a function parameter, but when I call the function it creates it's own set of numeric keys for the array. How can I make it use the same keys?
<?php
$param = [
"foo" => "bar",
"bar" => "foo",
];
function amazonRequest($AmazonQuery) {
$url = array();
foreach ($AmazonQuery as $key => $val) {
$key = str_replace("%7E", "~", rawurlencode($key));
$val = str_replace("%7E", "~", rawurlencode($val));
$url[] = "{$key}={$val}";
print_r($url);
}
}
amazonRequest($param);
print_r($param);