Conversion of PHP HTML entity characters

Source: Internet
Author: User
what function does PHP have to convert the HTML entity symbol é to é?

PHP that several functions have tried, no AH.


Reply to discussion (solution)

I don't know how you do it.

Let me give you a list of HTML entities supported by PHP
foreach (Get_html_translation_table (html_entities) as $k = = $v) {
Echo Ord ($k). ' = '. $v. Php_eol;
}

And then you can do it yourself.

Agree upstairs

It seems to support this symbol, weak weak question, which function should be used to convert?

I don't know how you do it.

Let me give you a list of HTML entities supported by PHP
foreach (Get_html_translation_table (html_entities) as $k = = $v) {
Echo Ord ($k). ' = '. $v. Php_eol;
}

And then you can do it yourself.

Echomb_convert_encoding ("é", "UTF-8", "html-entities"); E

Very good, then ask, if an article has a lot of such characters need to convert it? Can not be a change, there is no easier way?

PHP Code

Echo mb_convert_encoding ("é", "UTF-8", "html-entities");
E

Do you want to do this?

foreach (Get_html_translation_table (html_entities) as $k = = $v) {
$str = Str_replace ($v, mb_convert_encoding ($v, "GBK", "html-entities"), $STR);
}


Very good, then ask, if an article has a lot of such characters need to convert it? Can not be a change, there is no easier way? Reference to the 4 floor of the reply:

PHP Code

Echo mb_convert_encoding ("é", "UTF-8", "html-entities");
E

Html_entity_decode

$text = mb_convert_encoding ($text, "UTF-8", "html-entities");

You're still a cow. Solve the problems that have plagued me for a long time. I can sleep tonight.

$text = mb_convert_encoding ($text, "UTF-8", "html-entities");

Still have a problem ah, those characters are turned clean. But ordinary characters such as spaces are not.
Like what
$str = ' class ' √ ';

$str = mb_convert_encoding ($str, "GBK", "html-entities");
Echo $str;

$text = mb_convert_encoding ($text, "UTF-8", "html-entities");

Html_entity_decode (' é ');

  • 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.