3v4l.org

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