3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function truncate($text, $max) { if (strlen($text) >= $max) { $text = ereg_replace("<[^>]*>", "", $text); $text = substr($text, 0, $max); $position = strrpos($text, " "); $text = substr($text, 0, $position)."..."; } return $text; } echo truncate('Lorem ipsum dolor <span>sit</span> amet !', 25); ?>
Output for 7.0.0 - 7.1.0
Fatal error: Uncaught Error: Call to undefined function ereg_replace() in /in/J1QIq:4 Stack trace: #0 /in/J1QIq(11): truncate('Lorem ipsum dol...', 25) #1 {main} thrown in /in/J1QIq on line 4
Process exited with code 255.
Output for 4.3.0 - 5.2.17, hhvm-3.10.0 - 3.12.0
Lorem ipsum dolor sit...
Output for 5.3.0 - 5.6.28
Deprecated: Function ereg_replace() is deprecated in /in/J1QIq on line 4 Lorem ipsum dolor sit...