fork(28) download
  1. <?php
  2. $s = "In the beginning there was a tree.";
  3. $max_length = 10;
  4.  
  5. if (strlen($s) > $max_length)
  6. {
  7. $offset = ($max_length - 3) - strlen($s);
  8. $s = substr($s, 0, strrpos($s, ' ', $offset)) . '...';
  9. }
  10.  
  11. echo $s;
  12. ?>
Success #stdin #stdout 0.03s 13064KB
stdin
Standard input is empty
stdout
In the...