Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here's a function modified from another I found online; it strips out any HTML, and cleans up some funky MS characters first; it then adds in an optional ellipsis character to the content to show that it's been shortened. It correctly splits at a word, so you won't have seemingly random characters;</p> <pre><code>/** * Function to ellipse-ify text to a specific length * * @param string $text The text to be ellipsified * @param int $max The maximum number of characters (to the word) that should be allowed * @param string $append The text to append to $text * @return string The shortened text * @author Brenley Dueck * @link http://www.brenelz.com/blog/2008/12/14/creating-an-ellipsis-in-php/ */ function ellipsis($text, $max=100, $append='&amp;hellip;') { if (strlen($text) &lt;= $max) return $text; $replacements = array( '|&lt;br /&gt;&lt;br /&gt;|' =&gt; ' ', '|&amp;nbsp;|' =&gt; ' ', '|&amp;rsquo;|' =&gt; '\'', '|&amp;lsquo;|' =&gt; '\'', '|&amp;ldquo;|' =&gt; '"', '|&amp;rdquo;|' =&gt; '"', ); $patterns = array_keys($replacements); $replacements = array_values($replacements); $text = preg_replace($patterns, $replacements, $text); // convert double newlines to spaces $text = strip_tags($text); // remove any html. we *only* want text $out = substr($text, 0, $max); if (strpos($text, ' ') === false) return $out.$append; return preg_replace('/(\W)&amp;(\W)/', '$1&amp;amp;$2', (preg_replace('/\W+$/', ' ', preg_replace('/\w+$/', '', $out)))) . $append; } </code></pre> <p>Input:</p> <p><code>&lt;p class="body"&gt;The latest grocery news is that the Kroger Co. is testing a new self-checkout technology. My question is: What&amp;rsquo;s in it for me?&lt;/p&gt; &lt;p&gt;Kroger said the system, from Fujitsu,</code></p> <p>Output:</p> <p><code>The latest grocery news is that the Kroger Co. is testing a new self-checkout technology. My question is: What's in it for me? Kroger said the …</code></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload