What encoding is the white space character in this string? The test code cannot be replaced with s:
$ 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!
Reply to discussion (solution)
Echo htmlspecialchars ($ str );
The object html is not a space, and the display effect is a space.
Thank you for your reply.
Can I add something to the regular expression preg_replace in the above code, and then remove this invisible blank space?
Then replace it.
Add a row...
$ 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 );
$ Str = preg_replace ("//", "", $ str );
Echo "str: $ str
";
It is also a blank HTML symbol
I know that "" is a blank sign. I don't know what to add to the above regular expression to remove the blank space after "1" in the string.
You just need to copy it. it's not a space character.
There is a large comment in the first part of the php page. how can I find out which one was written,
The content of the comment is as follows:
You just need to copy it. it's not a space character.
Moderator,
The blank is not a space, but I don't know how to remove it?
Change all double quotes to single quotes and try again.
Change all double quotes to single quotes and try again.
Changed. Similarly, the blank space cannot be removed.
Code:
$url = 'http://www.google.com/ig/calculator?hl=en&q=1USD=?tzs';$str = @file_get_contents( $url );$str = preg_replace('/"/', '\'', $str);$str = preg_replace('/[\s\v\t\r\n ]+/', '', $str);$str = preg_replace('/ /', '', $str);echo "str:$str";
Output result:
Str: {lhs: '1u. S. dollar ', rhs: '1 631.32137Tanzanianshillings', error: '', icc: true}
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.
Oh, you can!
Thank you!