Reputation: 4849
I have been banging my head in the wall for couple of hours, I still couldn't figure out the issue. I have an associative array and when I try to build a query with it, It shows weird characters in the browser.
$reportVars = [
"__report" => "alpha",
"start_date" => "2001",
"end_date" => "2002",
"dsp_id" => "SPP",
"current_sp_id" => "SPP_1",
"sp_name" => "fawzan"
];
print_r(http_build_query($reportVars));
This is the output I get in the browser
__report=alpha&start_date=2001&end_date=2002&dsp_id=SPP¤t_sp_id=SPP_1&sp_name=fawzan
Note the strange character (¤) in the output after SPP, Before you ask No, I did not copy it from anywhere. I just typed it with my bare hand.
Can anyone please help me here?
Upvotes: 1
Views: 81
Reputation: 3993
¤ is being converted to ¤
you may have few options now:
move the current_sp_id
to top, making it the first variable so that there is no &
before it
use &
as separator instead of &
only by using:
print_r(http_build_query($reportVars, '', '& amp;'));
(remove the space between &
and amp
, added it because it's being converted to & only here too).
P.S. php isn't causing this issue as per my understanding, it's how your browser treats ¤ by probably converting it to ¤ itself
Upvotes: 3