What is the encoding of the whitespace characters in this string? Can't replace with "s"

Source: Internet
Author: User
Test code:
$url = ' Http://www.google.com/ig/calculator?hl=en&q=1USD=?tzs ';
$str = @file_get_contents ($url);
$str = Preg_replace ("/[\s\v\t\r\n]+/", "", $str);
echo "str: $STR";

In the output, the blank character after the "1 631.32137Tanzanianshillings" front "1" is old.

Also please understand the friend pointing ah, thank you!


Reply to discussion (solution)

echo Htmlspecialchars ($STR);
The entity HTML is not a space, the effect is a space

Thank you for your reply.

Could you please add something to the preg_replace in the code above and then remove the invisible blank?

Then replace it, too.

Add a line, or the same ...

$url = ' Http://www.google.com/ig/calculator?hl=en&q=1USD=?tzs ';
$str = @file_get_contents ($url);
$str = Preg_replace ("/[\s\v\t\r\n]+/", "", $str);
$str = Preg_replace ("//", "", $str);
echo "STR: $STR
";

is also a blank HTML symbol

I know "" is a blank symbol, I do not know what to add in the above the regular point, in order to the string "1" after the blank to remove

You know, that's a little bit of a space.

PHP Page Header There is a large section of comment description, how to find out where it was written,
the contents of the comment are as follows:

* @copyright: Copyright 2006 FEIFENGXLQ * @license: Version 2.0 * @create: 2006-5-31 * @modify: 2006-6-1 * @modify: FEIFENGXLQ 2006-11-4 * Description: Ultra-strong paging class, four paging modes, default to similar baidu,google-like paging style. * 2.0 added function: Support custom style, custom style, support PHP4 and

You know, that's a little bit of a space.

Moderator Good Ah,
That blank is not a space, but do not know how to remove it?

First, put all the double quotes in single quotes and try again.

First, put all the double quotes in single quotes and try again.

Change it. Or the same, the blank will not go away.

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 "St R: $str ";


Output Result:
STR:{LHS: ' 1U. S.dollar ', RHS: ' 1 631.32137Tanzanianshillings ', error: ', icc:true}

In $str = @file_get_contents ($url);
$str =iconv ("GBK", "Utf-8//ignore", $str);
With this, the conversion can be replaced, because there are unrecognized characters in the acceptance process, so that a conversion can identify

Oh, that's OK!
Thank you Moderator!

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.