Fawzan Fawzan - 4 years ago 90
PHP Question

Strange encoding issue in PHP

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"



This is the output I get in the browser


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?

Answer Source

&curren is being converted to ¤

you may have few options now:

  1. move the current_sp_id to top, making it the first variable so that there is no & before it

  2. use &amp 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 &curren by probably converting it to ¤ itself

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download