Function __global->xhtml_substr

Definitions

sources/xhtml.php

  • XHTML-aware substring extraction. Note that it will strip images, linebreaks, rules, etc - it's intended really for inline XHTML.
  • Visibility: public
  • Is abstract?: No
  • Is static?: No
  • Is final?: No
  • Returns: string

Parameters

Name Type Passed by reference? Variadic? Default Set Range Description
$html string No No required parameter N/A N/A The text to perform on
$from integer No No required parameter N/A N/A The start position of the cut (HTML tags will be taken from before this though)
$length ?integer No No Null N/A N/A The length you want the concatenated text to be (null: go to end)
$literal_pos boolean No No False N/A N/A Whether to do a substr based on literal position in XHTML, rather than based on number of visible characters
$ellipses boolean No No False N/A N/A Whether to add ellipses
$grammar_completeness_tolerance float No No 0 N/A N/A A fraction of the length we may exceed by in order to maintain grammar tolerance (finish sentences, finish paragraphs, finish the whole thing)

Returns

  • The result
  • Type: string
  • Set: N/A
  • Range: N/A

Preview

Code (PHP)

/**
 * XHTML-aware substring extraction. Note that it will strip images, linebreaks, rules, etc - it's intended really for inline XHTML.
 *
 * @param  string $html The text to perform on
 * @param  integer $from The start position of the cut (HTML tags will be taken from before this though)
 * @param  ?integer $length The length you want the concatenated text to be (null: go to end)
 * @param  boolean $literal_pos Whether to do a substr based on literal position in XHTML, rather than based on number of visible characters
 * @param  boolean $ellipses Whether to add ellipses
 * @param  float $grammar_completeness_tolerance A fraction of the length we may exceed by in order to maintain grammar tolerance (finish sentences, finish paragraphs, finish the whole thing)
 * @return string The result
 */

function xhtml_substr(string $html, int $from, ?int $length = null, bool $literal_pos = false, bool $ellipses = false, float $grammar_completeness_tolerance = 0) : string