fork(1) download
  1. <?php
  2.  
  3. // your code goes here
  4. function check_plain($text) {
  5. return htmlspecialchars($text, ENT_QUOTES, 'UTF-8');
  6. }
  7.  
  8. $str = '<strong>&amp;foo<em class="bar">bar</em></strong>';
  9. $maxlength = 5;
  10.  
  11. $cutlength = $maxlength; while (0 < $delta = $maxlength - strlen(html_entity_decode(strip_tags(substr($str, 0, $cutlength))))) {$cutlength += $delta;}
  12. print $cutlength;
Success #stdin #stdout 0.01s 20568KB
stdin
Standard input is empty
stdout
33