What encoding is the white space character in this string? The test code cannot be replaced with & quot; s & quot;: $ url & nbsp; www. google. comigcalculator? Hlen & amp; q1USD? Tzs; $ str & nbsp; @ file_get_contents (& nbsp; $ url & nbsp;); what encoding is the blank character in this string? Cannot be replaced with "\ s"
Test code:
$ Url = 'http: // www.google.com/ig/calculator? Hl = en & q = 1 USD =? Tzs ';
$ Str = @ file_get_contents ($ url );
$ Str = preg_replace ("/[\ s \ v \ t \ r \ n] +/", "", $ str );
Echo "str: $ str ";
In the output result, the blank character after "1" at the beginning of "1 631.32137 Tanzanianshillings" cannot become old.
Please give me some advice. thank you!
Share:
------ Solution --------------------
Echo htmlspecialchars ($ str );
The object html is not a space, and the display effect is a space.
------ Solution --------------------
Then replace it.
------ Solution --------------------
It is also a blank HTML symbol
------ Solution --------------------
You just need to copy it. it's not a space character.
------ Solution --------------------
Change all double quotes to single quotes and try again.
------ Solution --------------------
Add $ str = @ file_get_contents ($ url );
$ Str = iconv ("GBK", "UTF-8 // IGNORE", $ str );
With this added, you can replace it by converting it. this is because there are unrecognizable characters in the acceptance process, so that the conversion can be recognized.