3v4l.org

run code in 300+ PHP versions simultaneously
<?php function niceAuthorsPrint(array $authors, $takeCount){ $totalAuthors = count( $authors ); $tailCount = $totalAuthors - $takeCount; $first = array_slice($authors, 0, $takeCount); $othersLabel = $tailCount == 1 ? 'other' : 'others'; $string = implode( ", ", $first ); if($tailCount > 0){ $string .= " and " . $tailCount . ' ' . $othersLabel; } return $string; } // take 3 echo niceAuthorsPrint(array( 'user1', 'user2', 'user3', 'user4', 'user5' ), 3) ."\n<br>"; // take 4 echo niceAuthorsPrint(array( 'user1', 'user2', 'user3', 'user4', 'user5' ), 4) ."\n<br>"; // take 5 echo niceAuthorsPrint(array( 'user1', 'user2', 'user3', 'user4', 'user5' ), 5) ."\n<br>"; ?>
Output for git.master, git.master_jit, rfc.property-hooks
user1, user2, user3 and 2 others <br>user1, user2, user3, user4 and 1 other <br>user1, user2, user3, user4, user5 <br>

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:
29.16 ms | 405 KiB | 5 Q