3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function check_plain($text) { return htmlspecialchars($text, ENT_QUOTES, 'UTF-8'); } $str = '<strong>foobar</strong>'; print strlen($str) . "\n"; $maxlength = 4; $cutlength = $maxlength; while (0 < $delta = $maxlength - strlen(check_plain(substr($str, 0, $cutlength)))) { $cutlength += $delta; } print substr($str, 0, $cutlength);
Output for 4.3.2 - 7.1.0
23 <str
Output for 4.3.0 - 4.3.1
23
Process exited with code 139.