decode_entities

Хочешь помочь с переводом? Это очень просто и быстро. Лишь зарегистрируйся, и можешь тут же начать переводить.

includes/unicode.inc, строка 296

Версии
5 – 6
decode_entities($text, $exclude = array())

Decode all HTML entities (including numerical ones) to regular UTF-8 bytes. Double-escaped entities will only be decoded once ('<' becomes '<', not '<').

Параметры

$text The text to decode entities in.

$exclude An array of characters which should not be decoded. For example, array('<', '&', '''). This affects both named and numerical entities.

▾ 6 функции вызывают decode_entities()

filter_xss_bad_protocol in modules/filter/filter.module
Обрабатывает значение HTML-аттрибута и проверяет, чтобы он не содержал URL с запрещённым протоколом (например, javascript:)
format_rss_channel in includes/common.inc
Formats an RSS channel.
search_simplify in modules/search/search.module
Simplifies a string according to indexing rules.
_comment_form_submit in modules/comment/comment.module
_filter_url_parse_full_links in modules/filter/filter.module
Make links out of absolute URLs.
_filter_url_parse_partial_links in modules/filter/filter.module
Make links out of domain names starting with 'www.'

Код

<?php
function decode_entities($text, $exclude = array()) {
  static $table;
  // We store named entities in a table for quick processing.
  if (!isset($table)) {
    // Get all named HTML entities.
    $table = array_flip(get_html_translation_table(HTML_ENTITIES));
    // PHP gives us ISO-8859-1 data, we need UTF-8.
    $table = array_map('utf8_encode', $table);
    // Add apostrophe (XML)
    $table['&apos;'] = "'";
  }
  $newtable = array_diff($table, $exclude);

  // Use a regexp to select all entities in one pass, to avoid decoding double-escaped entities twice.
  return preg_replace('/&(#x?)?([A-Za-z0-9]+);/e', '_decode_entities("$1", "$2", "$0", $newtable, $exclude)', $text);
}
?>
Войдите или зарегистрируйтесь, чтобы получить возможность отправлять комментарии

Вход в систему