Основной сайт хуманэмулятор.рф  |  Демо  |  Купить  |  API  |  Wiki



Web / webpage



html_to_text

html_to_text($html); - Получить текст из HTML кода

Функция на вход принимает параметры:

  • $html – HTML код

    После выполнения функции возвращаемое значение будет равно одному из двух :
  • результат – Текст без HTML тэгов
  • пусто / null – ошибка

    Пример использования
    <?php
    // Scenario: Convert HTML content to plain text
    
    $xhe_host = getenv("RPABOT_HOST_URL");
    if (!isset($path)) {
      // Path to the init.php file for connecting to the XHE API
      $path = "../../../Templates/init.php";
      // Including init.php grants access to all classes and functionality for working with the XHE API
      require($path);
    }
    
    // Start
    echo "\n<font color=blue>webpage->" . basename(__FILE__) . "</font>\n";
    
    // Example 1: Convert HTML to text
    $htmlContent = "<font color=red>Те<a href='/'>ст</a></font>";
    echo "1. Convert HTML to text: ";
    echo WEB::$webpage->html_to_text($htmlContent) . "\n";
    
    // End
    echo "\n";
    
    // Quit the application
    WINDOW::$app->quit();

    =============================================
    Webpage    Объекты    DOM  System  Vision  Web  Window        
    =============================================
    если что-то непонятно или необходимо узнать или считаете что надо добавить по работе этой функции, пишите в комментарии или на наш форум
    .