3v4l.org

run code in 300+ PHP versions simultaneously
<?php $strings = [ 'StackOverFlow is the best site ever', // 22 ----------------^ 'http://stackoverflow.com is the best site ever', // 22 ----------------^ 'Short string', // no ellipsis needed ^ 'pneumonoultramicroscopicsilicovolcanoconiosis', // breakpoint between ^ letters ]; $link = '<a href="/this/story">Read More</a>'; function ShortenText($text, $chars) { $chars = $chars;$text = $text." "; $countchars = strlen($text); if($countchars > $chars) { $text = substr($text,0,$chars); $text = substr($text,0,strrpos($text,' ')); $text = $text."..."; } return $text; } foreach ($strings as $string) { var_export( ShortenText($string, 22) ); echo "\n"; }
Output for git.master, git.master_jit, rfc.property-hooks
'StackOverFlow is the...' '...' 'Short string ' '...'

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
144.15 ms | 405 KiB | 5 Q